2011年4月28日

统计元音

摘要: #include<stdio.h>#include<string.h>int main( ){ int N; scanf("%d",&N); getchar(); while(N--) { char ch[300]; gets(ch); int i,j,len,a=0,e=0,t=0,o=0,u=0; len=strlen(ch); for(i=0;i<len;i++) if(ch[i]=='a') a++; else if(ch[i]=='e') e++; else if(ch[i]=='i&# 阅读全文

posted @ 2011-04-28 20:10 more think, more gains 阅读(148) 评论(0) 推荐(0)

首字母变大写

摘要: #include<stdio.h>#include<string.h>int main( ){ char ch[120]; while(gets(ch)) { int i,j,len; len=strlen(ch); for(i=0;i<len;i++) if(ch[i-1]==' '&&i!=0&&ch[i]!=' ') ch[i]=ch[i]-32; if(ch[0]!=' ') ch[0]=ch[0]-32; printf("%s\n",ch);}return 阅读全文

posted @ 2011-04-28 20:01 more think, more gains 阅读(164) 评论(0) 推荐(0)

查找最大元素

摘要: #include<stdio.h>#include<string.h>int main( ){ char ch[120],max; while(gets(ch)) { int i,j,len; len=strlen(ch); max=ch[0]; for(i=1;i<len;i++) if(ch[i]>max) max=ch[i]; for(i=0;i<len;i++) { printf("%c",ch[i]); if(ch[i]==max) printf("(max)");}puts("") 阅读全文

posted @ 2011-04-28 19:34 more think, more gains 阅读(141) 评论(0) 推荐(0)

合法标志符

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int fun(char a[ ]){ int i,t; t=strlen(a); if(a[0]>='0'&&a[0]<='9') return 0; else if(!((a[0]>='A'&&a[0]<='Z')||(a[0]>='a'&&a[0]<='z')||a[0] 阅读全文

posted @ 2011-04-28 19:23 more think, more gains 阅读(973) 评论(0) 推荐(0)

求平均成绩

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int main( ){ int N,M,i,j,k; float A[60][10],sum[60],B[60]; while(scanf("%d%d",&N,&M)!=EOF) { int num=0;k=0; memset(A,0,sizeof(A)); memset(B,0,sizeof(B)); memset(sum,0,sizeof(sum)); for(i=0;i<N;i++) for(j=0;j& 阅读全文

posted @ 2011-04-28 18:32 more think, more gains 阅读(163) 评论(0) 推荐(0)

海选女主角

摘要: #include<stdio.h>#include<math.h>int A[1000][1000];int main( ){ int N,M,i,j,k,max,p; while(scanf("%d%d",&N,&M)!=EOF) { for(i=1;i<=N;i++) for(j=1;j<=M;j++) scanf("%d",&A[i][j]); max=fabs(A[1][1]); k=1,p=1; for(i=1;i<=N;i++) for(j=1;j<=M;j++) if( 阅读全文

posted @ 2011-04-28 17:41 more think, more gains 阅读(164) 评论(0) 推荐(0)

发工资咯:

摘要: #include<stdio.h>int num=0;void fun(int x){ num+=x/100; x=x%100; num+=x/50; x=x%50; num+=x/10; x=x%10; num+=x/5; x=x%5; num+=x/2; x=x%2; num+=x/1;}int main( ){ int N,i,t; while(scanf("%d",&N)!=EOF,N) { for(i=1;i<=N;i++) { scanf("%d",&t); fun(t); } printf("%d 阅读全文

posted @ 2011-04-28 17:25 more think, more gains 阅读(162) 评论(0) 推荐(0)

绝对值排序

摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>int cmp(const void *a,const void *b){ return abs(*(int *)a)< abs(*(int *)b)?1:-1;}int main( ){ int N,A[10000]; while(scanf("%d",&N)... 阅读全文

posted @ 2011-04-28 16:58 more think, more gains 阅读(187) 评论(0) 推荐(0)

数列有序!

摘要: #include<stdio.h>int A[10000];int main( ){ int N,M,i,j,k; while(scanf("%d%d",&N,&M),N||M) { for(i=0;i<N;i++) scanf("%d",&A[i]); for(i=0;i<N;i++) if(M<=A[i]) { for(j=N-1;j>=i;j--) A[j+1]=A[j]; A[i]=M; ... 阅读全文

posted @ 2011-04-28 16:36 more think, more gains 阅读(135) 评论(0) 推荐(0)

母牛的故事

摘要: #include<stdio.h>int fun(int x){ if(x==1) return 1; else if(x==2) return 2; else if(x==3) return 3; else return fun(x-1)+fun(x-3);}int main( ){ int N; while(scanf("%d",&N)!=EOF,N) printf("%d\n",fun(N)); return 0;} 阅读全文

posted @ 2011-04-28 16:17 more think, more gains 阅读(158) 评论(0) 推荐(0)

字符串统计

摘要: #include<stdio.h>#include<string.h>int main( ){ int N; char ch[200]; scanf("%d",&N); while(N--) { int n=0,i; scanf("%s",ch); for(i=0;ch[i]!='\0';i++) if(ch[i]>='0'&&ch[i]<='9') n++; printf("%d\n",n);}return 0;} 阅读全文

posted @ 2011-04-28 16:12 more think, more gains 阅读(133) 评论(0) 推荐(0)

数据的交换输出

摘要: #include<stdio.h>void swap(int &x,int &y){ int temp; temp=x; x=y; y=temp;}int main( ){ int N,A[10000],i,j,min; while(scanf("%d",&N),N) { for(i=0;i<N;i++) scanf("%d",&A[i]); min=A[0]; j=0; for(i=1;i<N;i++) if(A[i]<min) { min=A[i]; j=i; } swap(A[0],A[ 阅读全文

posted @ 2011-04-28 16:06 more think, more gains 阅读(167) 评论(0) 推荐(0)

偶数求和

摘要: #include<stdio.h>int main(){ int N,i,j,k,M; while(scanf("%d%d",&N,&M)!=EOF) { int sum=0,k=0,flag=1; for(i=2;i<=2*N;i=i+2) { sum+=i; k++; if(k==M) printf(flag?"%d":" %d",sum/M),sum=0,k=0,flag=0; else if(i==2*N&&k!=M) printf(flag?"%d":&q 阅读全文

posted @ 2011-04-28 15:59 more think, more gains 阅读(156) 评论(0) 推荐(0)

还是打分那个,我不用函数啦。。。。。。竟然0ms…

摘要: #include<stdio.h>int main( ){ int N,i,A[110],j,k; while(scanf("%d",&N)!=EOF) { double sum=0,min,max; for(i=0;i<N;i++) scanf("%d",&A[i]); max=min=A[0]; j=k=0; for(i=1;i<N;i++) if(A[i]<min) { min=A[i]; j=i; } else if(A[i]>max) { max=A[i]; k=i; } A[j]=0; A[ 阅读全文

posted @ 2011-04-28 15:37 more think, more gains 阅读(163) 评论(0) 推荐(0)

青年歌手大奖赛_评委会打分

摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>int cmp(const void *a,const void *b){ return *(double * )a > *(double *)b ? 1: -1;}int main( ){ int N; while(scanf("%d",&N)!=EOF) { double sum=0; double A[10000]; int i; memset(A,0,sizeof(A)); for(i=0;i<N;i++) 阅读全文

posted @ 2011-04-28 15:22 more think, more gains 阅读(193) 评论(0) 推荐(0)

蟠桃记

摘要: #include<stdio.h>int fun(int x){ int sum=1,i; for(i=x;i>1;i--) sum=2*sum+2; return sum;}int main( ){ int N; while(scanf("%d",&N)!=EOF) printf("%d\n",fun(N)); return 0;} 阅读全文

posted @ 2011-04-28 14:57 more think, more gains 阅读(162) 评论(0) 推荐(0)

素数判定

摘要: #include<stdio.h>#include<math.h>int prime(int n){ int i; for(i=2;i<=sqrt(n);i++) { if(n%i==0) return 0; else if(i>sqrt(n)) return 1; }}int main( ){ int x,y,i; while(scanf("%d%d",&x,&y),x||y) { for(i=... 阅读全文

posted @ 2011-04-28 14:27 more think, more gains 阅读(145) 评论(0) 推荐(0)

多项式求和

摘要: #include<stdio.h>#include<math.h>int main( ){ int N,i,j,k,t; float p; scanf("%d",&N); for(i=1;i<=N;i++) { scanf("%d",&t); double sum=0;k=1,p=1; for(j=1;k<=t;k++) { sum+=j/p; p++; j=-j; } printf("%.2lf\n",sum); } return 0; }整除时注意,不能都是int型 阅读全文

posted @ 2011-04-28 14:15 more think, more gains 阅读(158) 评论(0) 推荐(0)

水仙花数

摘要: #include<stdio.h>int main( ){ int N,M; while(scanf("%d%d",&N,&M)!=EOF) { int i,j,k,X,flag=1; for(X=N;X<=M;X++) { i=X/100; j=X/10-i*10; k=X-100*i-10*j; if(i*i*i+j*j*j+k*k*k==X) printf(flag?"%d":" %d",X),flag=0; if(X==M&&!flag) puts(""); 阅读全文

posted @ 2011-04-28 13:56 more think, more gains 阅读(129) 评论(0) 推荐(0)

求数列的和

摘要: #include<stdio.h>#include<math.h>int main( ){ int N,M,i; while(scanf("%d%d",&N,&M)!=EOF) { double sum=0,p=N; for(i=0;i<M;i++) sum+=p,p=sqrt(p); printf("%.2lf\n",sum); } return 0;} 阅读全文

posted @ 2011-04-28 12:32 more think, more gains 阅读(129) 评论(0) 推荐(0)

数值统计

摘要: #include<stdio.h>int main( ){ int N; while(scanf("%d",&N)!=EOF,N) { int i,n=0,m=0,p=0; double t; for(i=1;i<=N;i++) { scanf("%lf",&t); if(t<0) n++; else if(t==0) m++; else p++; } printf("%d %d %d\n",n,... 阅读全文

posted @ 2011-04-28 12:24 more think, more gains 阅读(156) 评论(0) 推荐(0)

平方和与立方和

摘要: #include<stdio.h>int main( ){ int N,M,i; while(scanf("%d%d",&N,&M)!=EOF) { int t1=0,t2=0; if( N > M ) N ^= M ^= N ^= M; for(i=N;i<=M;i++) if(i%2) t1+=i*i*i; else t2+=i*i; printf("%d %d\n",t2,t1);}return 0;} 这么简单的一道题,提交 wrong answer..打击啊。。立哥说要判断N是否大于M??一改就对啦。 阅读全文

posted @ 2011-04-28 12:19 more think, more gains 阅读(164) 评论(0) 推荐(0)

求奇数的乘积

摘要: #include<stdio.h>int main( ){ int N; while(scanf("%d",&N)!=EOF) { int i,mul=1,t; for(i=1;i<=N;i++) { scanf("%d",&t); if(t%2==1) mul*=t; } printf("%d\n",mul);} return 0;} 阅读全文

posted @ 2011-04-28 12:06 more think, more gains 阅读(594) 评论(0) 推荐(0)

第几天?

摘要: #include<stdio.h>int fun(int y,int m,int d){ int sum=0,i; int A[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; for(i=1;i<m;i++) sum+=A[i]; sum+=d; if(y%4 ==0&&(y%100!=0||y%400==0)&&(m>2)) sum++; return sum;} int main( ){ int Y,M,D; while(scanf("%d/%d/%d",&Y,&a 阅读全文

posted @ 2011-04-28 11:55 more think, more gains 阅读(144) 评论(0) 推荐(0)

成绩转换

摘要: #include<stdio.h>void fun(int x ){ int i; i=x/10; switch(i) { case 10:printf(x>100?"Score is error!\n":"A\n");break; case 9: puts("A");break; case 8: puts("B");break; case 7: puts("C");break; case 6: ... 阅读全文

posted @ 2011-04-28 11:28 more think, more gains 阅读(168) 评论(0) 推荐(0)

求绝对值

摘要: #include<stdio.h> #include<math.h> int main( ) { double t; while(scanf("%lf",&t)!=EOF) printf("%.2lf\n",fabs(t)); return 0; } 阅读全文

posted @ 2011-04-28 11:09 more think, more gains 阅读(142) 评论(0) 推荐(0)

计算球体积

摘要: #include<stdio.h>#define PI 3.1415927int main( ){ double r; while(scanf("%lf",&r)!=EOF) printf("%.3lf\n",PI*4*r*r*r/3); return 0;} 阅读全文

posted @ 2011-04-28 11:05 more think, more gains 阅读(179) 评论(0) 推荐(0)

ASCII码排序

摘要: #include<stdio.h>int main( ){ char ch[10]; while(scanf("%s",ch)!=EOF) { int a,b,c,temp; a=ch[0]-48; b=ch[1]-48; c=ch[2]-48; if(a<b) {temp=a;a=b;b=temp;} if(a<c) {temp=a;a=c;c=temp;} if(b<c) {temp=b;b=c;c=temp;} printf("%c %c %c\n",c+48,b+48,a+48); } return 0;} 阅读全文

posted @ 2011-04-28 11:02 more think, more gains 阅读(151) 评论(0) 推荐(0)

计算两点间的距离

摘要: #include<stdio.h>#include<math.h>int main( ){ double x1,y1,x2,y2; while(scanf("%lf",&x1)!=EOF) { scanf("%lf%lf%lf",&y1,&x2,&y2); printf("%.2lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));}return 0;} 阅读全文

posted @ 2011-04-28 10:56 more think, more gains 阅读(147) 评论(0) 推荐(0)

导航