Компьютерный форум NoWa.cc Здесь может быть Ваша реклама
Правила Форума
редакция от 22.06.2020
Форум .::NoWa.cc::.
Вернуться   Компьютерный форум NoWa.cc > В помощь вебмастеру > Программирование > Visual C++ / С/C++

Уважаемые пользователи nowa.cc. Мы работаем для вас более 20 лет и сейчас вынуждены просить о финансовой помощи по оплате за сервер.
Окажите посильную поддержку, мы очень надеемся на вас. Реквизиты для переводов ниже.
Webmoney Webmoney WMZ: Z021474945171 Webmoney WME: E159284508897 Webmoney WMUSDT: T206853643180
Кошелёк для вашей помощи YooMoney 4100117770549562
YooMoney Спасибо за поддержку!

 
 
Опции темы Опции просмотра Language
Старый 01.05.2008, 05:07   #1
Неактивный пользователь
 
Пол:Мужской
Регистрация: 18.03.2008
Сообщений: 6
Репутация: 0
Exclamation Помогите(сдавать срочно)-Сосчитать Гласные и Согласные в словах(код внутри)



Написал программу- Сосчитать Гласные и Согласные в словах
У меня считает только в последней введенной строчке(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;
}

большое спасибо!!!!
XXXAlex вне форума
 
Ответить с цитированием Вверх
 


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Помогите срочно! 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

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Быстрый переход


Текущее время: 03:48. Часовой пояс GMT +3.


Copyright ©2004 - 2025 NoWa.cc

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2026, vBulletin Solutions, Inc. Перевод: zCarot
Время генерации страницы 0.05669 секунды с 12 запросами