码迷,mamicode.com
首页 > 其他好文 > 详细

xxx

时间:2019-02-11 20:08:28      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:while   git   .cpp   white   and   enter   isp   let   xxx   

// cctypes.cpp -- using the ctype.h library #include <iostream> #include <cctype> // prototypes for character functions int main() { using namespace std; cout << "Enter text for analysis, and type @" " to terminate input.\n"; char ch; int whitespace = 0; int digits = 0; int chars = 0; int punct = 0; int others = 0; cin.get(ch); // get first character while (ch != ‘@‘) // test for sentinel { if(isalpha(ch)) // is it an alphabetic character? chars++; else if(isspace(ch)) // is it a whitespace character? whitespace++; else if(isdigit(ch)) // is it a digit? digits++; else if(ispunct(ch)) // is it punctuation? punct++; else others++; cin.get(ch); // get next character } cout << chars << " letters, " << whitespace << " whitespace, " << digits << " digits, " << punct << " punctuations, " << others << " others.\n"; // cin.get(); // cin.get(); return 0; }

xxx

标签:while   git   .cpp   white   and   enter   isp   let   xxx   

原文地址:http://blog.51cto.com/13471554/2349264

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!