当前位置:三九宝宝网 → 宝宝教育 → 写作范文 → 正文

C程序:循环输入字符分别统计出每次循环英文字母空格数字

更新:01-03 整理:39baobao.com
字体:

[求一份英文简历]个人简历一般应简要写明本人所受教育、专业兴趣、工作经历、所取得的成绩及家庭背景。 有关个人简历写作的注意要点。综合各校的要求,特做如下分析: 1.个人简历的结构可分为三...+阅读

#include void count(char c); int letters=0,space=0,digit=0,others=0; /*定义为全局变量*/ main() {char c; printf("you can input your sentences.\n"); /*放在FOR外*/ for(;c!='\n';) { count(c=getchar()); } printf("all in all:char=%d space=%d digit=%d others=%d\n",letters, space,digit,others); } void count(char c) { if(c>='a'&&c<='z'||c>='A'&&c<='Z') letters++; else if(c==' ') space++; else if(c>='0'&&c<='9') digit++; else if(c='\n') ; else others++; } 调试过,符合你要求! 你的主要错误是: count中的那些变量是局部的 每调用一次就分配一次内存,调用完释放! 不可能可以累加! count 里面的那个while 传一个C进去 只要不是\n 它就进死循环! printf("you can input your sentences.\n"); 这句应该放在for循环外 要不会出现很多次!

本文地址:https://www.39baobao.com/show/33_26737.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

英文个人简介怎么写Good morning teachers! I'm glad to introduce myself here. My name is... I'm ...years old and graduated from... I recieved preschool education in my school. I am...

急需励志性质的英文诗或英文励志的歌曲:Hero - Mariah Carey,她自己创作的经典曲目,知道这首歌将近十年,每次唱起来依然能给我鼓劲~ I Believe I can Fly - R.Kelly,《太空大灌篮》的主题歌,很上口 When You...

英文励志诗歌 Try Try agian急求Try Try Again by T. H. Palmer 'Tis a lesson you should heed, If at first you don't succeed, Try, try again; Then your courage should appear, For if you will per...

谁能给我一首英文励志的诗歌、THE SIGNIFICANCE OF FAILURE Robert H. Schuller Failure doesn't mean you are a failure, It does mean you have't succeeded yet. Failure doesn't mean you have ac...

求一篇计算机应用的200字的英文作文The Internet transforms modern life (互联网改变现代生活) most people had to call the bank to check their balances,or wait for a paper statement to arrive in the m...

猎场 21集中的那首英文歌曲叫什么名字《猎场》第21集的那首英文插曲是《Scarborough Fair》(斯卡波罗集市)原唱歌手为保罗·西蒙(Paul Simon)和阿特·加芬克尔(Art Garfunkel)。莎拉·布莱曼(Sarah Brightman)翻唱过该歌...

大家给推荐下高雅的英文精选欧美歌曲:~~~~~~~~个人珍藏,绝非复制,绝对精挑细选!!!~~~~~~~~ Carpenters-Yesterday Once More mariah carey-without you groove coverage-far away from home Maria Arredo...

英文的新学期的打算就写几条建议!新的一个学期,我也要在英语课上有新的打算,新的进步。 A new semester, I will be in English class, the new progress in a new plan. 首先,每天上课认真听,每天回家按时最好...

1输入一行字符分别统计出其中英文字母空格数字和其他字符的#include <stdio.h> int main(int argc, char *argv[]) { int i[4]={0,0,0,0}; char a; while((a=getchar())!='\n') { if(a>='0'&a<='9') i[0]++;//数字 else if((a>='a'&a<...