最新湖南工业大学C语言考试题目.doc

上传人:日度 文档编号:145968250 上传时间:2020-09-25 格式:DOCX 页数:14 大小:141.66KB
返回 下载 相关 举报
最新湖南工业大学C语言考试题目.doc_第1页
第1页 / 共14页
最新湖南工业大学C语言考试题目.doc_第2页
第2页 / 共14页
最新湖南工业大学C语言考试题目.doc_第3页
第3页 / 共14页
最新湖南工业大学C语言考试题目.doc_第4页
第4页 / 共14页
最新湖南工业大学C语言考试题目.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《最新湖南工业大学C语言考试题目.doc》由会员分享,可在线阅读,更多相关《最新湖南工业大学C语言考试题目.doc(14页珍藏版)》请在金锄头文库上搜索。

1、湖南工业大学C语言题目1、#include 改错 #include int arrmax( int arr33) int i,j,max; max=arr00; /*found*/ for ( i=0; i3; i+) 此处将1改为0,并且去掉等号 for ( j=0; j3; j+) if (max arrij) max = arrij; return (max); void main() int a33=4,4,34,7,3,12,5,6,5,i,j; /*found*/ printf(The max is: %dn,arrmax(a); 将arrmax(a00)改为arrmax(a) 2

2、、#define M 10 #include void main( ) int i,a100,t; /clrscr(); for(i=0;iM;i+) /*found*/ ai=i+1; /*found*/ for(i=0;iM/2;i+) aM-i-1=ai;for(i=0;iM;i+) printf(%5d,ai); printf(n); 3、#include 编辑 #include int fun(int m) /*begin*/int a1,a2,a3,s;a1=m/100;a2=m%100/10;a3=m%10;s=a1+a2+a3;return(s); /*end*/ void m

3、ain() int m,s; /clrscr(); printf(Enter m :n); scanf(%d,&m); s=fun(m); printf(Result is: %dn,s);4、#include 改错 #include main() int a10=10,4,2,7,3,12,5,34,5,9,i,s; clrscr(); s = 0; /*found*/ for ( i=0; i10; i+) 去掉等号 if (ai % 2 = 0) /*found*/ s = s + ai; 将i改为ai printf(The result is: %dn, s); 5、#include

4、填空 #include void main( ) int num,k; /clrscr() ; /*found*/ k=0; 给k赋值 printf(Please enter a number:) ; scanf(%d,&num) ; do /*found*/ k=k+num%10 ; num%10可求出num的各位 num/=10; while(num) ; printf(n%dn,k) ; 6、#include 改错 #include #include void main() int i,j,x,p; /clrscr(); x=1; /*found*/ j=12; while(j1) 去掉

5、等号 p=(x+1)*2; /*found*/ x=p; j-; printf(total is %dn,p); 7、#include stdio.h 改错 void main() long int f20=1,1; int i;/clrscr(); /*found*/ f0=1;f1=1; 赋初值 for(i=0;i20;i+) fi+2=fi+fi+1; 保证前面两个数要输出,所以要这样改/*found*/ if(i%5=0) printf(n); i%5=0保证一行5个数输出 printf(%8ld,fi); printf(n); 8、#include 编辑 #include #incl

6、ude double fun(double x) /*begin*/ int q; double n,t,s; n=1; s=0; t=1; q=1; while(fabs(t)=x) s=s+t; n=n+2; q=-q; t=q/n; return s; /*end*/ void main() double x,sum; printf(Enter x:n); scanf(%lf,&x); sum=fun(x);printf(sum=%.4fn,sum) NONO( ); 9、#include 改错 #include int max; fun ( int arr,int n ) int po

7、s,i; max = arr0; pos = 0; for ( i=1; in; i+) if (max arri) max = arri; /*found*/ pos= i; return (pos); void main() int a10=1,4,2,7,3,12,5,34,5,9,n; /clrscr(); /*found*/ n = fun(a,10); printf(The max is: %d ,pos is: %dn, max , n); 10、#include stdio.h 编辑 #include math.h #include conio.h #include stdli

8、b.h void main() int m=6,n=45,t,i,temp;/*begin*/ temp=n*m; while(m!=0) i=n%m; n=m; m=i; t=temp/n; 注: 此时最大公约数是n,要通过此程序会求最大公约数 最小公倍数等于两个数的乘积除以它们的最大公约数 /*end*/ printf(The Lowest Common Multiple of %d and %d is %dn,m,n,t); NONO(m,n,t); 11、#include 填空 #include #include main() int m,n,i,t; long int s=0; /c

9、lrscr(); scanf(%d,%d,&m,&n); if( mn ) t=m; m=n; n=t; /*found*/ for (i=m;i=n;i+) if ( i%3=0 & i%7=0 ) s += i; /*found*/ printf(Sum is : %ldn,s ); 12 #include 填空 void main() long s, t, sl=1; int d; /clrscr(); printf(nPlease enter s:); scanf(%ld, &s); t = 0; while ( s 0) d = s%10; /*found*/ if (d%2=0) 判断余数 t=d * sl + t; sl *= 10; /*found*/ s =s/10; 遇到奇数退出寻环后的处理

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号