2、多少天:#includeintsum_day(intyear,intmonth,intday);voidmain(){intyear,month,day;intdays;printf("请输入要查询的年月日");scanf("%d%d%d",&year,&month,&day);days=sum_day(year,month,day);printf("该天是%d天",days);}inttab[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};ints
3、um_day(intyear,intmonth,intday){inti,days=0;if(year%4==0&&year%100!=0
4、
5、year%400==0)tab[2]=29;for(i=1;iintisprime(inta);voidmain()仅供学习与交流,如有侵权请联系网站删除谢谢5精品好文档,推荐学习交流{intx;printf("请输入要判断的
6、正整数:");scanf("%d",&x);if(isprime(x))printf("%d是素数",x);elseprintf("%d不是素数",x);}4.计算矩阵对角线元素之和:#includevoidmain(){inti,j,a[5][5],sum=0,n=5;for(i=0;i<5;i++){printf("行%d:",j);for(j=0;j<5;j++){scanf("%d",&a[i][j]);if(i==j)sum+=a[i][j];if(i+j==4)sum+=a
7、[i][j];sum-=a[2][2];}}}5.斐波拉契数列:(1)#includevoidmain(){intA[20];inti;A[0]=1;A[1]=1;for(i=2;i<20;i++)A[i]=A[i-1]+A[i-2];for(i=0;i<20;i++){printf("%d",A[i]);if((i+1)%5==0)printf("");}仅供学习与交流,如有侵权请联系网站删除谢谢5精品好文档,推荐学习交流}(2)#includeintfibo(intn);
8、voidmain(){inti;for(i=1;i<=20;i++){printf("%d",fibo(i));if(i%5==0)printf("");}}intfibo(intn){intk;if(n==1)k=1;elseif(n==2)k=1;elsek=fibo(n-1)+fibo(n-2);returnk;}6.查询数字:#includevoidmain(){inta[10],left=0,right=10,mid,i,j;printf("请按从小到大的顺序输入被查询序列的10个数
9、:");for(i=0;i<=9;i++)scanf("%d",&a[i]);printf("请输入待查询的整数:");scanf("%d",&j);while(left<=right){mid=(left+right)/2;if(a[mid]==j){printf("待查询数字在%d位",mid+1);break;}elseif(a[mid]>j)right=mid-1;elseif(a[mid]right)printf("待查询数字不在此序列");仅供学习与
10、交流,如有侵权请联系网站删除谢谢5精品好文档,推荐学习交流}7.统计字符串:#includeintp(chara[],charb[]){inti=0,j=0,k=0;for(i=0;a[i];i++){j=i;for(k=0;a[j]==b[k]&&b[k]&&a[j];j++,k++);if(!b[k])return++i;}return