C语言考试系统题库.doc

上传人:大张伟 文档编号:7194893 上传时间:2020-11-04 格式:DOC 页数:6 大小:132.01KB
返回 下载 相关 举报
C语言考试系统题库.doc_第1页
第1页 / 共6页
C语言考试系统题库.doc_第2页
第2页 / 共6页
C语言考试系统题库.doc_第3页
第3页 / 共6页
C语言考试系统题库.doc_第4页
第4页 / 共6页
C语言考试系统题库.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《C语言考试系统题库.doc》由会员分享,可在线阅读,更多相关《C语言考试系统题库.doc(6页珍藏版)》请在三一文库上搜索。

1、#include #include void main() int arr10=11,4,2,7,3,12,5,34,5,9,i; int s=0; /*found*/ for ( i=0; i10; i+) /*found*/ if (arri % 2 = 1) s = s + arri; printf(The result is: %dn, s); #include stdio.h#include string.hvoid main( ) char s10; unsigned i;/*found*/ int n=0; scanf(%s,s);/*found*/for(i=0;istrlen

2、(s);i+) n=n*10+si-0; printf(n=%ldn,n);#include #include double average( int arr , int n ) int k=0,i; double s; s = 0; for ( i=0 ;in; i+) /*found*/ if (arri % 2 = 1) s = s + arri; k+; return (s/k) ; void main() int a12=10,4,2,7,3,12,5,34,5,9,21,18; double s; /*found*/ s = average(a,12); printf(The re

3、sult is: %.2fn, s); #include #include #include void main() int x,y,t,max,min,i,n1,n2; printf(Please enter two numbers:); scanf(%d,%d,&x,&y); if(x y) t = x; x = y; y = t; n1=x; n2=y; t = n2 % n1; /*found*/ while( n1n2 ) n2 = n1 ; n1 = t ; t = n2 % n1; /*found*/ max = t; min = x * y / max ; printf(max

4、 is : %dn,max); printf(min is : %dn,min); #include #define N 3 int fun(int aNN) int min; /*begin*/ int i,j; min=a00; for(i=0;iN;i+) for(j=0;jN;j+) if(aijmin)min=aij; /*end*/ return min; void main() void NONO( );/函数声明 int aNN=-1,2,3,4,9,5,7,8,6; int i,j,min; printf(array is:n); for(i=0;iN;i+) for(j=0

5、;jN;j+) printf(%5d,aij); printf(n); min=fun(a); printf(Result is: %dn,min); NONO( ); void NONO( ) FILE *fr,*fw; int i,j,k,m,aNN; fr=fopen(D:exam05910327PROGIN.DAT,r); fw=fopen(D:exam05910327PROGOUT.DAT,w); for(i=1;i=5;i+) for(j=0;jN;j+) for(k=0;kN;k+) fscanf(fr,%d,&ajk); fprintf(fw,%4d,ajk); fprintf

6、(fw,Min = %dn,fun(a); fclose(fr); fclose(fw); #include #include void main() int a33=4,4,34,37,3,12,5,6,5,i,j,max,min; max = min = a00; for ( i=0; i3; i+) /*found*/ for ( j=0; j3; j+) if ( max aij) min = aij; printf(The max is: %dn, max); printf(The min is: %dn, min); #include #include #include void

7、main() int a12=2,3,5,7,8,9,10,11,12,13,15,17,i,j,k,s; /*found*/ s=0; for ( i=0; i12; i+) k=(int)sqrt(ai); for ( j=2;j k ) /*found*/ s=s+ai; printf(Sum is: %dn,s); #include #define M 100 void main() int a,b,i; a=0;b=0; /*found*/ for(i=1;i=M;i+=2) a+=i; /*found*/ b+=i+1; printf(sum of evens is %dn,b);

8、 printf(sum of odds is %dn,a); #include #include #include void main() int a12=2,3,5,7,8,9,10,11,12,13,15,17,i,j,k,s; /*found*/ s=0; for ( i=0; i12; i+) k=(int)sqrt(ai); for ( j=2;j k ) /*found*/ s=s+ai; printf(Sum is: %dn,s); #include #include int fun(char str1,char ch) /*begin*/ /*end*/ void main()

9、 void NONO( );/函数声明 char str180,ch; int count; printf(Enter str1:n); gets(str1); printf(Enter ch:n); ch=getchar(); count=fun(str1,ch); printf(Result is: %dn,count); NONO( ); void NONO( ) FILE *fr,*fw; int i, count; char str80, ch; fr=fopen(D:exam05910327PROGIN.DAT,r); fw=fopen(D:exam05910327PROGOUT.DAT,w); for(i=1; i=2; i+) fscanf(fr,%s,str);fgetc(fr); ch=fgetc(fr); count=fun(str,ch); fprintf(fw,Result is :#%dn,count); fclose(fr); fclose(fw);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1