湖南工业大学C语言考试摸拟题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
#include
void main()
{ int arr[10]={11,4,2,7,3,12,5,34,5,9},i;
int s=0;
/************found************/
for ( i=0; i<10; i++)
/************found************/ if (arr[i] % 2 == 1)
s = s + arr[i];
printf("The result is: %d\n", s);
}
#include "stdio.h"
#include "string.h"
void main( )
{
char s[10];
unsigned i;
/**************found************/
int n=0;
scanf("%s",s);
/**************found************/ for(i=0;i n=n*10+s[i]-'0'; printf("n=%ld\n",n); } #include s = 0; for ( i=0 ;i /************found************/ if (arr[i] % 2 == 1) { s = s + arr[i]; k++; } return (s/k) ; } void main() { int a[12]={10,4,2,7,3,12,5,34,5,9,21,18}; double s; /************found************/ s = average(a,12); printf("The result is: %.2f\n", 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( n1>n2 ) { n2 = n1 ; n1 = t ; t = n2 % n1; } /************found************/ max = t; min = x * y / max ; printf("max is : %d\n",max); printf("min is : %d\n",min); } #include int min; /***********begin***********/ int i,j; min=a[0][0]; for(i=0;i {for(j=0;j {if(a[i][j] /************end************/ return min; } void main() { void NONO( );//函数声明 int a[N][N]={-1,2,3,4,9,5,7,8,6}; int i,j,min; printf("array is:\n"); for(i=0;i { for(j=0;j printf("%5d",a[i][j]); printf("\n"); } min=fun(a); printf("Result is: %d\n",min); NONO( ); } void NONO( ) { FILE *fr,*fw; int i,j,k,m,a[N][N]; fr=fopen("D:\\exam\\05910327\\PROGIN.DAT","r"); fw=fopen("D:\\exam\\05910327\\PROGOUT.DAT","w"); for(i=1;i<=5;i++) { for(j=0;j for(k=0;k { fscanf(fr,"%d",&a[j][k]); fprintf(fw,"%4d",a[j][k]);} fprintf(fw,"Min = %d\n",fun(a));} fclose(fr); fclose(fw); } #include #include void main() { int a[3][3]={4,4,34,37,3,12,5,6,5},i,j,max,min; max = min = a[0][0]; for ( i=0; i<3; i++) /************found************/ for ( j=0; j<3; j++) { if ( max < a[i][j] ) max = a[i][j]; /************found************/ if (min > a[i][j]) min = a[i][j]; } printf("The max is: %d\n", max); printf("The min is: %d\n", min); }