找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

帖子
查看: 2439|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

c語(yǔ)言 統(tǒng)計(jì)不同類型字符數(shù)

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:72519 發(fā)表于 2015-1-22 02:46 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#include<stdio.h>//統(tǒng)計(jì)不同類型字符數(shù)
void main()
{char c;
        int e=0,s=0,n=0,o=0;//這樣輸入是錯(cuò)誤的:e=s=n=o=1,為什么呢?
printf("please input random characteristics,use enter to end the string\n");
for(;(c=getchar())!='\n';)//斜杠好像被我打反了
{
if((c>=65&&c<=90)||(c>=97&&c<=122))
e++;
else if((c>=48&&c<=57))
n++;
else if(c==32)
s++;
else
o++;
}
printf("the number of english characteristic is %d\n",e);
printf("the number of  space is %d\n",s);
printf("the number of number is %d\n",n);
printf("the number of other characteristics is %d\n",o);
}

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩

相關(guān)帖子

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表