![]() |
|
| Правила Форума редакция от 22.06.2020 |
|
|||||||
|
|
Окажите посильную поддержку, мы очень надеемся на вас. Реквизиты для переводов ниже. |
|
|
|
Опции темы | Опции просмотра |
Language
|
|
|
#1
|
|
Неактивный пользователь
Пол:
Регистрация: 18.03.2008
Сообщений: 6
Репутация: 0
|
![]() Написал программу- Сосчитать Гласные и Согласные в словах У меня считает только в последней введенной строчке(Kellogg Competition) а не в первой(Puu Kaa Lani) и поэтому я немогу сосчитать максимальный(highest ratio) и минимальный(lowest ratio) коэфицент между первой и второй строчкой. Помогите чуть доделать программу Some languages use many more vowels than others. For example, in Hawaiian “Puu Kaa Lani” has 6 vowels and 4 consonants. Write a program that inputs a line of text, calculates the ratio of vowels to consonants and prints that line with the corresponding ratio. Numbers, spaces and punctuation do not count, for example May 26, 1999 has a ratio of 1 /2. The program should repeat the process until the user enters an empty line. At the end, it should write the lines with the highest and lowest ratio. It should count only letters, disregarding any other character. Note: A, a, E, e, I, I, O, o, U, u are vowels(гласные) and other letters are consonants(согласные). Вот так должно выглядеть: Sample Input and Output: Please enter any text> Puu Kaa Lani Do you wish to continue? (Y/N) Y Please enter any text> Kellogg Competition Do you wish to continue? (Y/N) N “Puu Kaa Lani” vowel to consonant ratio is: 6/4 “Kellogg Competition ” vowel to consonant ratio is: 7/11 The line with the lowest ratio is: “Kellogg Competition” ratio vowel to consonant is: 0.6 The line with the highest ratio is: “Puu Kaa Lani” vowel to consonant ratio: 1.5 Код:
#include "stdafx.h"
#include "conio.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
char retry = 'y';
string s;
int vowels=0;
int consonant=0;
int lowest=0;
int highest=0;
while (retry == 'y' || retry == 'Y')
{
cout <<"\nPlease enter text: ";
cin >> s;
cout << "\nDo you wish to continue? (Y/N)"<<endl;
cin >> retry;
}
for (int i=0; i<int(s.size()); ++i)
{
if (s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u'
|| s[i]=='A' || s[i]=='E' || s[i]=='I' || s[i]=='O' || s[i]=='U')
++vowels;
else
++consonant;
}
cout << "\nTotal vowels are: "<<vowels << endl;
cout << "\nTotal Consonants are: "<< consonant << endl;
cout << "\nConsonant ratio are: "<< vowels << "/" << consonant << endl;
if ( vowels <= consonant )
cout << "\nThe line with the lowest ratio: " << lowest << endl;
cout << "\nThe line with the highest ratio is: "<< highest << endl;
_getch();
return 0;
}
большое спасибо!!!! ![]() |
|
|
|
Похожие темы
|
||||
| Тема | Автор | Раздел | Ответов | Последнее сообщение |
| Помогите срочно! | AnnaS | Скорая помощь | 11 | 14.03.2010 00:18 |
| Как сосчитать одинаковые записи в БД. | hack | Delphi | 6 | 17.02.2010 11:36 |
| помогите пожалуста c программой на с++(сдавать срочно) | XXXAlex | Visual C++ / С/C++ | 2 | 19.03.2008 05:30 |
| ??????помогите срочно | LISER | Архив | 2 | 20.01.2008 19:51 |
| Жизнь в ста словах . . . | Mademoiselle | Творчество наших читателей | 8 | 12.06.2007 15:18 |
|
|