![]() |
#2
sunkaidong2008-03-08 13:08
|
//作用是统计空格数,制表符,换行符的个数,能够通过编译,但是,出不来结果!!
#include <iostream>
using namespace std;
int main()
{
int blank(0),tab(0),enter(0),other(0);
char ch;
while(ch=cin.get())
switch(ch)
{
case ' ':++blank;break;
case '\t':++tab;break;
case '\n':++enter;break;
default:++other;
}
cout<<"blank:"<<blank<<endl;
cout<<"tab:"<<tab<<endl;
cout<<"enter:"<<enter<<endl;
cout<<"other:"<<other<<endl;
return 0;
}