zoukankan      html  css  js  c++  java
  • 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7

    #include <iostream>
    #include <string>
    #include <cctype>
    using namespace std;
    int main()
    {
    	string words;
    	int yy=0;
    	int fy=0;
    	int other=0;
    	cout<<"Enter words (q to quit):
    ";
    	while(cin>>words)
    	{
    		if(isalpha(words[0]))
    		{
    			if(words[0]=='q' && (words.size())==1)
    				break;
    			else
    			{
    				switch(words[0])
    				{
    				case 'a':
    				case 'o':
    				case 'e':
    				case 'i':
    				case 'u':
    					yy++;
    					break;
    				default:fy++;
    				}
    			}
    		}
    		else
    			other++;
      }
     cout<<yy<<" words beginning with vowels"<<endl;
     cout<<fy<<" words beginning with consonants"<<endl;
     cout<<other<<" others"<<endl;
     system("pause");
     return 0;
    }
    
  • 相关阅读:
    闭包
    线程与进程
    异常处理
    socket编程
    面向对象编程
    模块
    正则表达式
    递归、二分查找、冒泡算法
    装饰器
    迭代器与生成器
  • 原文地址:https://www.cnblogs.com/lynnycy/p/3454833.html
Copyright © 2011-2022 走看看