南昌大学C语言考试题库(共34页).doc
《南昌大学C语言考试题库(共34页).doc》由会员分享,可在线阅读,更多相关《南昌大学C语言考试题库(共34页).doc(34页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上一、阅读程序写出程序运行结果阅读以下程序并写出其运行结果#include #include int fun(char s,int c) char *q=s; for(; *q; q+) if(*q != c) *(s+)=*q; *s=0; main() static char str=turbo c and borland c+; char ch; fun(str,c); printf(str=%sn,str); system(pause);程序的运行结果是str=turbo and Borland +阅读以下程序并写出其运行结果#include #include
2、void fun(int a, int b, long *c) *c=a/10*10+a%10*1000+b/10*100+b%10; main() int a=42,b=25; long c; fun(a, b, &c); printf(The result is: %ldn, c); system(pause);程序的运行结果是 the result is: 2245 请按任意键继续阅读以下程序并写出其运行结果#include void fun(int *s, int nl, int n2) int i, j, t ; i=nl; j=n2; while(ij) t=si; si=sj;
3、sj=t; i+; j-; main() int a10=1,2,3,4,5,6,7,8,9,0,k;fun(a,0,3); fun(a,4,9); fun(a,0,9); for(k=0;k10;k+)printf(“%d”,ak); printf(“n”); 程序运行的结果是 Press any key to continue阅读以下程序并写出其运行结果#include main() int i=1; while(!(i%2=1)&(i%3=2)&(i%5=4)&(i%6=5)&(i%7=0) +i; printf(n The ladder has %d stages.n,i); 程序的运
4、行结果是阅读以下程序并写出其运行结果#include #define ROW 3#define COL 4main()int matrixAROWCOL=11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22; int matrixBCOLROW;int i,j;printf(%d*%d:n,ROW,COL);for( i=0; iROW; i+ ) for( j=0; jCOL; j+ )matrixBji = matrixAij;printf(MatrixB,);printf(%d*%d:n,COL,ROW);for( i=0; iCOL; i+ )f
5、or( j=0; jROW; j+ )printf(%8d,matrixBij);printf(n);system(pause);程序的运行结果是3*4 Matrix B 4*311 15 1912 16 2013 17 2114 18 22阅读以下程序并写出其运行结果#include #define N 10main()int primesN;int pc,m,k;printf(n The first %d prime numbers are:n,N);primes0=2;pc =1;m =3;while(pcN)k=0;while(primesk*primesk=m)if(m%primes
6、k=0) m+=2; k=1;elsek+;primespc+=m;m+=2;for(k=0;kpc;k+)printf(%4d,primesk);system(pause);程序的运行结果是the fiest 10 prime numbers are2 3 5 7 11 13 17 19 23 29阅读以下程序并写出其运行结果#include #include void fun(char *s ,int n) char *t; int i,j; for(i=0;in-1;i+) for(j=i+1;jstrlen(sj) t=si;si=sj;sj=t;main() char *ss=“bc
7、c”,”bbcc”,”xy”,”aaaacc”,”aabcc” ;fun(ss,5); printf(“%s,%sn”,ss0,ss4);程序的运行结果是阅读以下程序并写出其运行结果#include void fun(char *a, char *b) while(*a=*) a+; while(*b=*a) b+;a+;main() char *s=”*a*b*”,t80;fun(s,t); puts(t); 程序的运行结果是阅读以下程序并写出其运行结果#include main() FILE *fp; int a10=1,2,3,i,n;fp=fopen(“dl.dat”,”w”);for
8、(i=0;i3;i+) fprintf(fp,”%d”,ai);fprintf(fp,”n”);fclose(fp);fp=fopen(“dl.dat”,”r”);fscanf(fp,”%d”,&n);fclose(fp);printf(“%dn”,n);程序的运行结果是阅读以下程序并写出其运行结果#include void swap( int *a, int *b ) int *t ; t=a; a=b; b=t; main() int i=3,j=5,*p=&i,*q=&j; swap(p,q); printf(“%d %dn”,*p,*q); 程序的运行结果是阅读以下程序并写出其运行结果
9、int circle(int n, int d)int s=0,m=n;while(m)s=s*d+m%d;m/=d;return s=n;int num=232,27,851;int scale=2,10,16;main()int i,j;for(i=0;isizeof(num)/sizeof(num0);i+)for(j=0;j (%d) is a Circle Number!n,numi,scalej);elseprintf(%d - (%d) is not a Circle Number!n,numi,scalej);程序的运行结果是 答案太长不想写阅读以下程序并写出其运行结果#inc
10、lude #define NULL 0int *search2(int *pa,int *pb,int an,int bn)int *ca,*cb;ca=pa;cb=pb;while(capa+an&cbpb+bn)if(*ca*cb) cb+;elsereturn ca;/*返回在这两个数表中找到相等元素*/return NULL;main( )int *vp,i;int a =1,3,5,7,9,13,15,27,29,37;int b =2,4,6,8,10,13,14,27,29,37;puts(The elements of array a is:);for(i=0;isizeof(
11、a)/sizeof(a0);i+)printf( %d,ai);puts(nThe elements of array b is:);for(i=0;isizeof(b)/sizeof(b0);i+)printf( %d,bi);vp=search2(a,b,sizeof a/sizeof a0,sizeof b/sizeof b0);if(vp) printf(nThe first same number in both arrays is %dn,*vp);else printf(Not found!n);程序的运行结果是阅读以下程序并写出其运行结果#include main()int i
12、, j;char ch;i=1;while(i=5)j=1;ch=a;while(j=i)printf(%2c, ch);ch=ch+1;j+;printf(n);i+; 程序的运行结果是阅读以下程序并写出其运行结果#include rest(int a, int n)int i,low,high,t;for(i=0,low=0,high=n-1;i0)t=ai;ai=ahigh;ahigh=t;high-;else if(ai=0)i+;elset=ai;ai=alow;alow=t;low+;i+;int s=8,4,0,-1,6,0,-5;main()int i;printf(n The
13、 arry before rest is:n);for(i=0;isizeof(s)/sizeof(s0);i+)printf(%4d,si);rest(s,sizeof(s)/sizeof(s0);printf(n The arry after rest is:n);for(i=0;isizeof(s)/sizeof(s0);i+)printf(%4d,si);程序的运行结果是the arry before rest is 8 4 0 -1 6 0 -5 the arry after rest is -5 -1 0 0 6 4 8阅读以下程序并写出其运行结果#include #include
14、 typedef struct char name9; char sex; float score2; STU;void f( STU a) STU b=“Zhao” ,m,85.0,90.0 ; int i;strcpy(a.name,b.name);a.sex=b.sex;for(i=0;i2;i+) a.scorei=b.scorei;main() STU c=“Qian”,p,95.0,92.0;f(c); printf(“%s,%c,%2.0f,%2.0fn”,c.name,c.sex,c.score0,c.score1); 程序的运行结果是阅读以下程序并写出其运行结果 #inclu
15、de main() int x,y,z,j=0; printf(n The possible plans to buy 100 fowls with 100 Yuan are:nn); for(x=0;x=20;x+) for(y=0;y=33;y+) z=100-x-y; if(z%3=0&5*x+3*y+z/3=100) printf(%2d: cock=%2d hen=%2d chicken=%2dn,+j,x,y,z); 程序的运行结果是阅读以下程序并写出其运行结果#include void fun(int x) if(x/20) fun(x/2); printf(“%d ”,x);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 南昌大学 语言 考试 题库 34
限制150内