街球学者2 街球学者2
关注数: 6 粉丝数: 8 发帖数: 929 关注贴吧数: 4
问个有关文件输入的问题!这程序错在哪里…… 想要统计文件中字母的个数,可是给出的结果一直是0,应该怎么改? #include<stdio.h> #include<string.h> int main(int argc,const char*argv[]) { const char Inputfile[]="c:input.txt"; int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0, p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0; const int LEN=2,LE=1; char word[LE],ex[LEN]; FILE *fi; printf("The input file is %s\n",Inputfile); fi=fopen(Inputfile,"r"); if (fi==NULL) { printf("The file %s can not be opened.\n",Inputfile); } else{ while(fgets(ex,LEN,fi)!=NULL) { sscanf(ex,"%s",word); switch(word[LE]) { case 'a': a+=1; continue; case 'b': b+=1; continue; case 'c': c+=1; continue; case 'd': d+=1; continue; case 'e': e+=1; continue; case 'f': f+=1; continue; case 'g': g+=1; continue; case 'h': h+=1; continue; case 'i': i+=1; continue; case 'j': j+=1; continue; case 'k': k+=1; continue; case 'l': l+=1; continue; ca****+=1; continue; case 'n': n+=1; continue; case 'o': o+=1; continue; case 'p': p+=1; continue; case 'q': q+=1; continue; case 'r': r+=1; continue; case 's': s+=1; continue; case 't': t+=1; continue; case 'u': u+=1; continue; case 'v': v+=1; continue; case 'w': w+=1; continue; case 'x': x+=1; continue; case 'y': y+=1; continue; case 'z': z+=1; continue; } } printf("Total letters are %d, a appeared %d times,b appeared %d times, c appeared %d times,d appeared %d times, e appeared %d times, f appeared %d times,g appeared %d times, h appeared %d times,i appeared %d times, j appeared %d times,k appeared %d times, l appeared %d times,m appeared %d times, n appeared %d times,o appeared %d times, p appeared %d times,q appeared %d times, r appeared %d times,s appeared %d times, t appeared %d times,u appeared %d times, v appeared %d times,w appeared %d times, x appeared %d times,y appeared %dtimes, z appeared %d times.", a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z, a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); } fclose(fi); }
火箭队近况评述(个人) 昨天输给爵士,我觉得很不该,至少火箭自身存在很大问题。看下首发阵容:阿尔斯通,麦迪,巴蒂尔,海耶斯,斯科拉。 麦迪一上场火箭控卫就受到限制,尤其是阿尔斯通,基本变成了一个投手,而布鲁克斯还能发挥出作用,他的突破和投篮比阿尔斯通好些。 麦迪身体和心理不够坚强,打首发的话到下半场就没精力了,觉得还是替补适合他。(替补不丢人)巴蒂尔……火箭队近年来最糟糕的交易就是把他换来了……去年火箭进攻乏力,就是因为三号位上基本没有进攻能力,而实际上,小前锋应是得分能力最强的,得的分甚至比得分后卫还多。兰德里、斯科拉防守都不错,会遭犯规,巴蒂尔在队中作用很小。 海耶斯……很好的蓝领球员,但在进攻端能力不行。 斯科拉倒可以,没有问题。 就阵容来看,我认为应该全力培养布鲁克斯、兰德里、斯科拉等新秀,首发阵容可以是:布鲁克斯,海德,威尔斯,斯科拉(兰德里),姚明。麦迪打首发效果不好。 现在火箭状态不好,应寻求交易,可交易球员如下:阿尔斯通,巴蒂尔,海耶斯,(詹姆斯、麦迪)火箭作为一支强队,阿尔斯通的突破、得分能力达不到火箭队控卫的要求,而替补又应具有冲击力,所以阿尔斯通适合被交易。布鲁克斯应全力培养,小个子控卫成功的例子有很多,远游埃弗森、近有保罗,保罗不就是新秀赛季经常打满全场吗?交易阿尔斯通不是说他不好,而是说他具有交易价值。巴蒂尔的情况前面已讲过,某些重视防守的球队也许需要他。海耶斯是名好球员,交易他在感情上有点舍不得,但火箭的确不能指望他。他有一定交易价值。詹姆斯和麦迪估计交易不掉……麦迪可能是火箭的包袱,但交易他涉及太广,须谨慎。请大家不要口水,欢迎提出改进意见。
1 下一页