上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: #include<stdio.h>int main(){ int a[15]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int i,n,low,high,mid,flag; while(scanf("%d",&n)!=EOF) { flag=-1; low=0; high=14; while(low<high) { mid=(low+high)/2; if(n>a[mid]) low=mid+1; else if(n<a[mid]) high=mid; else { flag=mid; break; 阅读全文
posted @ 2012-05-30 14:57 尔滨之夏 阅读(193) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ int m,n,i,a,b,c,z,d; while(scanf("%d%d",&m,&n)!=EOF) { d=0;z=0; if(m>=100&&m<=999&&n>=100&&n<=999&&m<=n) { z=0; for(i=m;i<=n;i++) { a=i/100; b=i%100/10; c=... 阅读全文
posted @ 2012-05-28 21:33 尔滨之夏 阅读(536) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>void main(){ extern void enter_string(char str[]); extern void delete_string(char str[],char ch); extern void print_string(char str[]); char c; char str[80]; enter_string(str); scanf("%c",&c); delete_string(str,c); print_string(str);}#include<stdio.h>void e 阅读全文
posted @ 2012-05-27 20:57 尔滨之夏 阅读(627) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ char string[81]; int i,num=0,word=0; char c; gets(string); for(i=0;(c=string[i])!='\0';i++) if(c==' ') word=0; else if(word==0) { num++; word=1; } printf("%d\n",num); return 0;} 阅读全文
posted @ 2012-05-26 15:45 尔滨之夏 阅读(405) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>int cmp(const void*p1,const void*p2){ return *(int*)p1>*(int*)p2;}int main(){ int a[20]; int i,n; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) scanf("%d",&a[i]); qsort(a,n,sizeof(a[0]),cmp); for(i=0;i<n;i++) printf( 阅读全文
posted @ 2012-05-24 21:33 尔滨之夏 阅读(185) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ float score,aver,s=0; int i,n=0; for(i=1;i<5;i++) { printf("please enter score:"); scanf("%f",&score); if(score<60) { printf("%7.2f\n",score); continue; } s=s+score; n=n+1; } aver=s/n; printf("%d,%7.2f\n",n,aver); r 阅读全文
posted @ 2012-05-24 12:41 尔滨之夏 阅读(1012) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ long int f1,f2; int i; f1=1;f2=1; for(i=1;i<=20;i++) { printf("%12ld%12ld",f1,f2); if(i%2==0) printf("\n"); f1=f1+f2; f2=f2+f1; } return 0;}结果: 1 1 2 3 5 8 13 21 34 ... 阅读全文
posted @ 2012-05-24 12:29 尔滨之夏 阅读(8572) 评论(0) 推荐(0) 编辑
摘要: 注意分析n,循环次数与n不一样,要减一#include<stdio.h>int main(){ float score,sum=0,average; int i,n; for(i=1;i<31;i++) { scanf("%f",&score); if(score<0) break; sum=sum+score; } n=i-1; average=sum/n; printf("%d\n%f\n",n,average); return 0;} 阅读全文
posted @ 2012-05-23 22:16 尔滨之夏 阅读(531) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ double p=1.30756e9,r=0.01; int y; for(y=2006;p<1.5e9;y++) { p=p*(1+r); } printf("%d\n%e\n",y-1,p); return 0;} 阅读全文
posted @ 2012-05-23 22:10 尔滨之夏 阅读(283) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ float amount,sum=0; do{ scanf("%f",&amount); sum=sum+amount; }while(sum<10000); printf("%f\n",sum); return 0;} 阅读全文
posted @ 2012-05-23 21:11 尔滨之夏 阅读(212) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 下一页