资源描述:
《C语言80面上机题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、上机题十#includevoidmain(){intcount(intx);inti,t;for(i=1;i<=1000;i++){t=count(i);if(t%2!=0){printf("%d",i);}}}intcount(intx){inti,n=0;for(i=1;i<=x;i++){if(x%i==0){n++;}}returnn;}149162536496481100121144169196225256289324361400441484529576625676729784841900961Pressanykeytocontinuei
2、ntprime(int);#includevoidmain(){inti,a,b,c,d,e,f,j,k,l,m,q;for(i=1;i<=5000;i++){a=i;b=i;c=i;d=i;while(a!=0){e=a%10;f=prime(e);if(f==0){j=f;break;}else{j=1;a/=10;}}while(b!=0){k=prime(b);if(k==0){l=k;break;}else{l=1;b/=10;}}m=prime(c);q=m;printf("%d",q);if(q){printf("%d",d);}
3、}}printf("%d",m);}}}intprime(intx){inti,s=0;if(x<=1){return0;}else{for(i=1;i<=x;i++){if(x%i==0){s+=i;}if(s==(x+1)){return1;}else{return0;}}}}806.1#include#includevoidmain(){intn,i=1;longs=0;scanf("%d",&n);if(n>=1&&n<=9){while(i<=n){s+=pow(i,i);i++;}printf("%d",s);}el
4、se{printf("您的输入有误,请重新输入");}}806.2#includeintf131(intx){inti,s=0;if(x<=1){return0;}else{for(i=1;i<=x;i++){if(x%i==0){s+=i;}}if(s==(x+1)){return1;}else{return0;}}}voidmain(){intx,t;scanf("%d",&x);t=f131(x);if(t==1)printf("是");elseprintf("不是");}806.3#include#include<
5、math.h>doubleg(double,double);voidmain(){doublex,y,s;scanf("%lf,%lf",&x,&y);s=g(x,y);printf("%lf",s);}doubleg(doublex,doubley){doubles,v;if(x<=y){v=(1+exp(-(x+y)))/(1+exp(x+y));}elsev=(1+exp(-x+y))/(1+exp(x-y));s=v/(x+y);returns;}816.4#includeintdigit(int,int);voidmain(){intn,
6、k,s;scanf("%d,%d",&n,&k);s=digit(n,k);printf("%d",s);}intdigit(intn,intk){intt,i=0;while(iintf131(intx){inti,s=0;if(x<=1){return0;}else{for(i=1;i<=x;i++){if(x%i==0){s+=i;}}if(s==(x+1)){return1;}else{return0;}}}vo
7、idmain(){inta,b,c,t;scanf("%d",&a);while(a!=0){t=a%10;b=f131(t);if(b==0){c=b;}else{c=1;}a/=10;}if(c==1)printf("是");elseprintf("不是");}806.6(2)#includeintf131(intx);voidmain(){intm,i,j;printf("请输入一大于五的奇数:");scanf("%d",&m);if(m%2!=0&&m>5){for(i=2;i