![[計算機軟件及應用]c語言題庫套題1_第1頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/9ffe4cee-b1ec-415e-b87c-d198ac6b438e/9ffe4cee-b1ec-415e-b87c-d198ac6b438e1.gif)
![[計算機軟件及應用]c語言題庫套題1_第2頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/9ffe4cee-b1ec-415e-b87c-d198ac6b438e/9ffe4cee-b1ec-415e-b87c-d198ac6b438e2.gif)
![[計算機軟件及應用]c語言題庫套題1_第3頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/9ffe4cee-b1ec-415e-b87c-d198ac6b438e/9ffe4cee-b1ec-415e-b87c-d198ac6b438e3.gif)
![[計算機軟件及應用]c語言題庫套題1_第4頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/9ffe4cee-b1ec-415e-b87c-d198ac6b438e/9ffe4cee-b1ec-415e-b87c-d198ac6b438e4.gif)
![[計算機軟件及應用]c語言題庫套題1_第5頁](http://file3.renrendoc.com/fileroot_temp3/2021-12/11/9ffe4cee-b1ec-415e-b87c-d198ac6b438e/9ffe4cee-b1ec-415e-b87c-d198ac6b438e5.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、優質文本/*-【程序填空】-功能:識別輸入的字符串,每個單詞輸出一行-*/#include <stdio.h>#include <string.h>void main() int c; int inspace; /*SPACE*/ 【?】; while(c = getchar() != 'n') if(c = ' ' | c = 't' | c = 'n') /*SPACE*/ if(【?】) inspace = 1; putchar('n'); else inspace = 0; /*SP
2、ACE*/ 【?】; /*-【程序填空】-功能:求兩個非負整數的最大公約數和最小公倍數。-*/#include <stdio.h>main() int m,n,r,p,gcd,lcm; scanf("%d%d",&m,&n); if(m<n) p=m,m=n;n=p; p=m*n; r=m%n; /*SPACE*/ while(【?】 ) /*SPACE*/ m=n;n=r; 【?】; /*SPACE*/ gcd=【?】; lcm=p/gcd; /*SPACE*/ printf("gcd=%d,lcm=%dn", 【?】
3、);/*- 【程序改錯】-功能:將s所指字符串中的字母轉換為按字母序列的后續字母但 Z轉換為A, z轉換為a,其它字符不變。-*/#include <stdio.h>#include <ctype.h>#include <conio.h>void fun (char *s) /*FOUND*/ while(*s!="0") if(*s>='A' && *s <= 'Z' | *s >= 'a' && *s<='z') i
4、f(*s='Z') *s='A' else if(*s='z') *s='a' else /*FOUND*/ s += 1; /*FOUND*/ s+ main() char s80; printf("n Enter a string with length < 80. :nn "); gets(s); printf("n The string : nn "); puts(s); fun ( s ); printf ("nn The Cords :nn "); pu
5、ts(s);/*-【程序填空】-功能:輸入三個整數x,y,z,請把這三個數由小到大輸出。-*/#include <stdio.h>main() int x,y,z,t; scanf("%d%d%d",&x,&y,&z); /*SPACE*/ if (x>y)【?】 /*SPACE*/ if(x>z)【?】 /*SPACE*/ if(y>z)【?】 printf("small to big: %d %d %dn",x,y,z);/*-【程序填空】-功能:以下程序的功能如(圖1)。-*/#include
6、<stdio.h>#include <math.h>main() int f; /*SPACE*/ 【?】; double t,pi; t=1;pi=t;f=1;n=1.0; /*SPACE*/ while(【?】 ) n=n+2; /*SPACE*/ 【?】; t=f/n; pi=pi+t; /*SPACE*/ 【?】; printf("pi=%10.6fn",pi);/*- 【程序改錯】-功能:從鍵盤輸入十個學生的成績,統計最高分,最低分和平均分。 max代表最高分,min代表最低分,avg代表平均分。-*/#include <stdio.
7、h>main( ) int i; /*FOUND*/ float a8,min,max,avg; printf("input 10 score:"); for(i=0;i<=9;i+) printf("input a score of student:"); /*FOUND*/ scanf("%f",a); /*FOUND*/ max=min=avg=a1; for(i=1;i<=9;i+) /*FOUND*/ if(min<ai) min=ai; if(max<ai) max=ai; avg=avg+a
8、i; avg=avg/10; printf("max:%fnmin:%fnavg:%fn",max,min,avg);/*-【程序填空】-功能:用條件編譯方法實現以下功能。輸入一行電報文字,可以任 選兩種方式輸出,一種為原文輸出;另一種將字母變成下 一個字母如a變成b,C變成D,其他字符不變輸出。-*/#include <stdio.h>#define CHANGEmain() /*SPACE*/ char str80,【?】=str; printf("input string:"); /*SPACE*/ gets【?】; printf(&q
9、uot;Output string:"); #ifdef CHANGE for(;*s!='0's+) if(*s>='a'&&*s<='z'|*s>='A'&&*s<='Z') (*s)+; if(*s>'Z'&&*s<'Z'+2) /*SPACE*/ 【?】; if(*s>'z') /*SPACE*/ *s=【?】; printf("%sn",s
10、tr); #else printf("%sn",str); #endif/*- 【程序改錯】-功能:以下程序把兩個數按由大到小的順序輸出來.-*/#include <stdio.h>/*FOUND*/swap( int *p1,*p2) int p; p=*p1; *p1=*p2; *p2=p;main( ) int a,b, *p,*q; printf("input a,b:"); /*FOUND*/ scanf("%d%d",a,b); p=&a; q=&b; if(a<b) s); printf
11、("a=%d,b=%dn",a,b); /*FOUND*/ printf("max=%d,min=%dn",p,q);/*-【程序填空】-功能:百馬百擔問題:有100匹馬,馱100擔貨,大馬馱三擔,中 馬馱2擔,兩匹小馬馱一擔,求大、中、小馬各多少匹?-*/#include <stdio.h>main() int hb,hm,hl,n=0; /*SPACE*/ for(hb=0;hb<=100;hb+=【?】) /*SPACE*/ for(hm=0;hm<=100-hb;hm+=【?】) /*SPACE*/ hl=100-hb-【
12、?】; /*SPACE*/ if(hb/3+hm/2+2*【?】=100) n+; printf("hb=%d,hm=%d,hl=%dn",hb/3,hm/2,2*hl); printf("n=%dn",n);/*- 【程序改錯】-功能:八進制轉換為十進制。-*/#include <stdio.h>main() /*FOUND*/ char p,s6; int n; p=s; gets(p); /*FOUND*/ n=0; /*FOUND*/ while(*(p)='0') n=n*8+*p-'0' p+; p
13、rintf("%d",n);/*-【程序填空】-功能:刪除一個字符串中的所有數字字符。-*/#include <stdio.h>void delnum(char *s) int i,j; /*SPACE*/ for(i=0,j=0; 【?】'0' ;i+) /*SPACE*/ if(si<'0'【?】 si>'9') /*SPACE*/ 【?】; j+; sj='0'main () char *item; printf("n input a string:n"); i
14、tem="" gets(item); /*SPACE*/ 【?】; printf("n%s",item);/*- 【程序改錯】-功能:寫一個函數,求一個字符串的長度,在main函數中輸入字 符串,并輸出其長度。-*/#include <stdio.h>#include <conio.h>int length(p)char *p; int n; n=0; /*FOUND*/ while(*p='0') n+; p+; return n;main() int len; /*FOUND*/ char *str20; pr
15、intf("please input a string:n"); scanf("%s",str); /*FOUND*/ len=length(str); printf("the string has %d characters.",len);/*-【程序填空】-功能:刪除字符串中的指定字符,字符串和要刪除的字符均由鍵盤 輸入。-*/#include <stdio.h>main() char str80,ch; int i,k=0; /*SPACE*/ gets(【?】); ch=getchar(); /*SPACE*/ f
16、or(i=0;【?】;i+) if(stri!=ch) /*SPACE*/ 【?】; k+; /*SPACE*/ 【?】; puts(str); /*-【程序填空】-功能:輸入一正整數n、打印1-n能夠組成的所有自然數集合 包含空集。-*/#include <stdio.h>#include <stdlib.h>#define MAXSiZE 20#define LOOP 1void main(void) int setMAXSiZE; int n, i; int position; char line100; printf("nAll Possible Su
17、bsets Generation by Lexical Order"); printf("n="); printf("nnNumber of Elements in the Set -> "); gets(line); n = atoi(line); printf("n"); position = 0; setposition = 1; while (LOOP) /*SPACE*/ printf("n%d", 【?】); for (i = 1; i <= position; i+) print
18、f(",%d", seti); printf(""); if (setposition < n) /*SPACE*/ set【?】 = setposition + 1; position+; else if (position != 0) set-position+; else /*SPACE*/ 【?】; /*- 【程序改錯】-功能:將s所指字符串的反序和正序進行連接形成一個新串放在 t所指的數組中。例如:當s所指的字符串的內容為"ABCD"時,t所指數組中 的內容為"DCBAABCD"。-*/#inclu
19、de <conio.h>#include <stdio.h>#include <string.h>/*FOUND*/void fun (char s, char t) int i, d; /*FOUND*/ d = len(s); /*FOUND*/ for (i = 1; i<d; i+) ti = sd - 1 - i ; for (i = 0; i<d; i+) t d + i = si; /*FOUND*/ t2*d = '/0'main() char s100, t100; printf("nPlease en
20、ter string S:"); scanf("%s", s); fun(s, t); printf("nThe result is: %sn", t);/*-【程序填空】-功能:輸入學生成績并顯示。-*/# include <stdio.h>struct student char number6; char name6; int score3; stu2;void output(struct student stu2);void main() int i, j; /*SPACE*/ for(i=0; i<2; 【?】) pr
21、intf("請輸入學生%d的成績:n", i+1); printf("學號:"); /*SPACE*/ scanf("%s", 【?】.number); printf("姓名:"); scanf("%s", ); for(j=0; j<3; j+) printf("成績 %d. ", j+1); /*SPACE*/ scanf("%d", 【?】.scorej); printf("n"); output(stu)
22、;void output(struct student stu2) int i, j; printf("學號 姓名 成績1 成績2 成績3n"); for(i=0; i<2; i+) /*SPACE*/ 【?】("%-6s%-6s", stui.number, ); for(j=0; j<3; j+) printf("%-8d", stui.scorej); printf("n"); /*-【程序填空】-功能:輸出1到100之間每位數的乘積大于每位數的和的數。例如:數字26,數位上數字
23、的乘積12大于數字之和8。-*/#include <stdio.h>main() int n,k=1,s=0,m; for(n=1;n<=100;n+) k=1; s=0; /*SPACE*/ 【?】 ; /*SPACE*/ while( 【?】 ) k*=m%10; s+=m%10; /*SPACE*/ 【?】; if(k>s) printf("%d ",n); /*-【程序填空】-功能:從讀入的整數數據中,統計大于零的整數個數和小于零的 整數個數。用輸入零來結束輸入,程序中用變量i統計大于 零的整數個數,用變量j統計小于零的整數個數。-*/#in
24、clude <stdio.h>main() int n,i,j; printf("Enter iNT number,with 0 to endn"); i=j=0; scanf("%d",&n); while(n!=0) /*SPACE*/ if(n>0)i=【?】; /*SPACE*/ if(n<0)j=【?】; /*SPACE*/ scanf("%d",【?】); printf("i=%4dn",i,j);【程序填空】-功能:有n個整數,使其前面各數順序向后移m個位置,最后m個數
25、 變成最前面的m個數-*/#include <stdio.h>/*SPACE*/move(【?】)int n,m,array20; int *p,array_end; /*SPACE*/ array_end=*(【?】); for(p=array+n-1;p>array;p-) /*SPACE*/ *p=*(【?】); *array=array_end; m-; if(m>0) move(array,n,m);main() int number20,n,m,i; printf("the total numbers is:"); scanf("
26、;%d",&n); printf("back m:"); scanf("%d",&m); for(i=0;i<n-1;i+) scanf("%d,",&numberi); scanf("%d",&numbern-1); /*SPACE*/ move(【?】); for(i=0;i<n-1;i+) printf("%d,",numberi); printf("%d",numbern-1);/*-【程序填空】-功能:將字母轉換
27、成密碼,轉換規那么是將當前字母變成其后的第 四個字母,但W變成A、X變成B、Y變成C、Z變成D。小寫字 母的轉換規那么同樣。-*/#include <stdio.h>main() char c; /*SPACE*/ while(c=【?】)!='n') /*SPACE*/ if(c>='a'&&c<='z')|(c>='A'&&c<='Z')【?】; /*SPACE*/ if(c>'Z'【?】c<='Z'
28、+4)|c>'z') c-=26; printf("%c",c); /*-【程序填空】-功能:一個自然數被 8 除余 1 ,所得的商被 8 除也余 1 ,再 將第二次的商被8 除后余7 ,最后得到一個商為a。又知這 個自然數被17除余4 ,所得的商被17除余15,最后得到一 個商是a的2倍。編寫程序求這個自然數。-*/#include <stdio.h>main( ) int i,n,a ; i=0 ; while(1) if(i%8=1) n=i/8 ; if(n%8=1) n=n/8 ; /*SPACE*/ if(n%8=7) 【?】
29、; if(i%17=4) n=i/17 ; if(n%17=15) n=n/17 ; if(2*a=n) printf("result=%dn",i) ; /*SPACE*/ 【?】 ; /*SPACE*/ 【?】; /*- 【程序改錯】-功能:輸入10個數,要求輸出這10個數的平均值-*/#include <stdio.h>double average(double array10) int i; double aver,sum=array0; /*FOUND*/ for(i=0;i<10;i+) sum=sum+arrayi; aver=sum/10.
30、0; return(aver);main( ) /*FOUND*/ int score10,aver ; int i; printf("input 10 scores:n"); for(i=0;i<10;i+) /*FOUND*/ scanf("%f", score); printf("n"); /*FOUND*/ aver=average(score10); printf("average score is %5.2f",aver);/*- 【程序改錯】-功能:編寫input()和output()函數輸入,
31、輸出5個學生的數據記錄。-*/#include <stdio.h>#define N 5struct student char num6; char name8; int score4; stuN;input(stu)struct student stu; /*FOUND*/ int i;j; for(i=0;i<N;i+) printf("n please input %d of %dn",i+1,N); printf("num: "); scanf("%s",&stui.num); printf(&quo
32、t;name: "); scanf("%s",); for(j=0;j<3;j+) /*FOUND*/ printf("score %d.",j); scanf("%d",&stui.scorej); printf("n"); print(stu)struct student stu; int i,j; printf("nNo. Name Sco1 Sco2 Sco3n"); /*FOUND*/ for(i=0;i<=N;i+) printf(&q
33、uot;%-6s%-10s",stui.num,); for(j=0;j<3;j+) printf("%-8d",stui.scorej); printf("n"); main() input(); print();-【程序填空】-功能:計算個人及各科平均成績及全班平均成績,并在屏幕上顯 示出來。-*/#include <stdio.h>#define M 5 /*定義符號常量 人數為5*/#define N 4 /*定義符號常量 課程為4*/main() int i,j; void aver(float s
34、coM+1N+1); static float scoreM+1N+1=78,85,83,65, 88,91,89,93, 72,65,54,75,86,88,75,60,69,60,50,72; aver(score); printf("學生編號 課程1 課程2 課程3 課程4 個人平均n"); for(i=0;i<M;i+) printf("學生%dt",i+1); /*SPACE*/ for(j=0;j<【?】;j+) printf("%6.1ft",scoreij); printf("n"); for(j=0;j<8*(N+2);j+) printf("-"); printf("n課程平均"); for(j=0;j<
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 張掖中考試題及答案
- 物業完整試題及答案
- 淘寶客服溝通培訓
- 路基施工(路基排水施工)
- 經驗交流活動策劃與實施
- 溫控設備管理員工培訓
- 2025年中國母嬰用品行業市場全景分析及前景機遇研判報告
- 2025生物課標培訓
- 針灸出科門診病例分析專題報告
- 籃球教學工作總結
- 目標探測與識別知到智慧樹章節測試課后答案2024年秋北京航空航天大學
- 安全附件管理培訓
- 寫字樓保安培訓資料
- 市政道路施工方案投標文件(技術方案)
- 08SS523建筑小區塑料排水檢查井
- 瑞得RTS-820系列全站儀說明書(適用RTS-822.822A.822L.822R.822R .822R3)
- 學生干部培訓2024年學生干部培訓方案
- 天津市西青區2023-2024學年八年級下學期期末歷史試卷(解析版)
- -投標技術標書范文模板-人員配備與團隊構建
- (正式版)YS∕T 5040-2024 有色金屬礦山工程項目可行性研究報告編制標準
- 貸款合同模板銀行版
評論
0/150
提交評論