收藏 分销(赏)

2023年C语言考试系统题库.doc

上传人:a199****6536 文档编号:3246808 上传时间:2024-06-26 格式:DOC 页数:9 大小:132.04KB
下载 相关 举报
2023年C语言考试系统题库.doc_第1页
第1页 / 共9页
2023年C语言考试系统题库.doc_第2页
第2页 / 共9页
点击查看更多>>
资源描述
#include <conio.h> #include <stdio.h> 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<strlen(s);i++) n=n*10+s[i]-'0'; printf("n=%ld\n",n); } #include <conio.h> #include <stdio.h> double average( int arr[ ], int n ) { int k=0,i; double s; s = 0; for ( i=0 ;i<n; 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 <math.h> #include <conio.h> #include <stdio.h> 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 <stdio.h> #define N 3 int fun(int a[N][N]) { int min; /***********begin***********/ int i,j; min=a[0][0]; for(i=0;i<N;i++) {for(j=0;j<N;j++) {if(a[i][j]<min)min=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<N;i++) { for(j=0;j<N;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<N;j++) for(k=0;k<N;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 <conio.h> #include <stdio.h> 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); } #include <math.h> #include <conio.h> #include <stdio.h> void main() { int a[12]={2,3,5,7,8,9,10,11,12,13,15,17},i,j,k,s; /************found************/ s=0; for ( i=0; i<12; i++) { k=(int)sqrt(a[i]); for ( j=2;j <= k; j++) if (a[i] % j == 0) break; if( j>k ) /************found************/ s=s+a[i]; } printf("Sum is: %d\n",s); } #include <stdio.h> #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 %d\n",b); printf("sum of odds is %d\n",a); } #include <math.h> #include <conio.h> #include <stdio.h> void main() { int a[12]={2,3,5,7,8,9,10,11,12,13,15,17},i,j,k,s; /************found************/ s=0; for ( i=0; i<12; i++) { k=(int)sqrt(a[i]); for ( j=2;j <= k; j++) if (a[i] % j == 0) break; if( j>k ) /************found************/ s=s+a[i]; } printf("Sum is: %d\n",s); } #include <string.h> #include <stdio.h> int fun(char str1[],char ch) { /***********begin***********/ /************end************/ } void main() { void NONO( );//函数申明 char str1[80],ch; int count; printf("Enter str1:\n"); gets(str1); printf("Enter ch:\n"); ch=getchar(); count=fun(str1,ch); printf("Result is: %d\n",count); NONO( ); } void NONO( ) {FILE *fr,*fw; int i, count; char str[80], ch; fr=fopen("D:\\exam\\05910327\\PROGIN.DAT","r"); fw=fopen("D:\\exam\\05910327\\PROGOUT.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 :##%d\n",count); } fclose(fr); fclose(fw); }
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传
相似文档                                   自信AI助手自信AI助手

当前位置:首页 > 通信科技 > 开发语言

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服