全文预览

“电子科技大学出版社(周信东主编)”的C语言程序设计实验-整理代码1_-9(精选)

上传者:似水流年 |  格式:doc  |  页数:13 |  大小:0KB

文档介绍
[i]);printf("\n");getchar();}--------------------------------------------------------#include"stdio.h"main(){inti=0;charstr1[255],str2[255];printf("\nInputstring1:");scanf("%s",str1);printf("\nInputstring2:");scanf("%s",str2);while(1){?if(str1[i]==str2[i])?{i++; continue;?}?else break;}printf("\n%d\n",str1[i]-str2[i]);}=====================实验八函数=====================8.1???????????????????未成功inta=3,b=5;max(inta,intb){?intc;?c=a>b?a:b;?return(c);}main(){?externinta,b;?printf("%d\n",max(a,b));}8.2#include<stdio.h>intis_prime(intm){ inti;?if(m==1) return0;?for(i=2;i<m;i++)?{ if(m%i==0) { return0; }?}?return1;}voidmain(){?intn,c;?scanf("%d",&n);?c=is_prime(n);?if(c==1) printf("prime\n"); else printf("notprime\n");}8.3#include<stdio.h>intmain(){intm,n,i,sum=1,t;printf("请输入m的值:\n");scanf("%d",&m);

收藏

分享

举报
下载此文档