freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

[工學(xué)]最新計(jì)算機(jī)2級(jí)c語言題庫-資料下載頁

2025-01-08 23:57本頁面
  

【正文】 的 中。 不得增行或刪行,也不得更改程序 的結(jié)構(gòu)! 給定源程序: include include define N 8 typedef struct list {int data。 struct list *next。 } SLIST。 SLIST *creatlist(char *)。 void outlist(SLIST *)。 int fun(SLIST *h, char ch) {SLIST *p。 int n=0。 p=hnext。 /**********found**********/ while(p!=___1___) {n++。 /**********found**********/ if (pdata==ch) return ___2___。 else p=pnext。 } return 0。 } main() {SLIST *head。 int k。 char ch。 char a[N]={39。m39。,39。p39。,39。g39。,39。a39。,39。w39。,39。x39。,39。r39。,39。d39。}。 head=creatlist(a)。 outlist(head)。 printf(Enter a letter:)。 scanf(%c,amp。ch)。 /**********found**********/ k=fun(___3___)。 if (k==0) printf(\nNot found!\n)。 else printf(The sequence number is : %d\n,k)。 } SLIST *creatlist(char *a) {SLIST *h,*p,*q。 int i。 h=p=(SLIST *)malloc(sizeof(SLIST))。 for(i=0。 iN。 i++) {q=(SLIST *)malloc(sizeof(SLIST))。 qdata=a[i]。 pnext=q。 p=q。 } pnext=0。 return h。 } void outlist(SLIST *h) {SLIST *p。 p=hnext。 if (p==NULL) printf(\nThe list is NULL!\n)。 else {printf(\nHead)。 do {printf(%c,pdata)。 p=pnext。} while(p!=NULL)。 printf(End\n)。 } } 解題答案 : /**********第一空 **********/ while(p!=0) /**********第二空 **********/ if (pdata==ch) return n。 /**********第三空 **********/ k=fun(head,ch)。 ****************************************** 二、改錯(cuò)題: 給定程序 中函數(shù) fun 的功能是 :刪除 p 所指字符串中的所有空白字符 (包括制表符、回車符及換行符 )。輸入字 符串時(shí)用 39。39。結(jié)束輸入。 請(qǐng)改正程序中的錯(cuò)誤,使它能輸出正確的結(jié)果。 注意:不要改動(dòng) main 函數(shù),不得增行或刪行,也不得更改程序的結(jié)構(gòu)! 給定源程序: include include include fun (char *p) {int i,t。 char c[80]。 /************found************/ For (i = 0,t = 0。 p[i] 。 i++) if(!isspace(*(p+i))) c[t++]=p[i]。 /************found************/ c[t]=\0。 strcpy(p,c)。 } main() {char c,s[80]。 int i=0。 printf(Input a string:)。 c=getchar()。 while(c!=39。39。) {s[i]=c。i++。c=getchar()。} s[i]=39。\039。 fun(s)。 puts(s)。 } 解題答案 : /************found************/ for(i=0,t=0。 p[i]。 i++) /************found************/ c[t]=39。\039。 ****************************************** 三、程序題: 請(qǐng)編寫一個(gè)函數(shù) fun,它的功能是:將 ss 所指字符串中所有下標(biāo)為奇數(shù)位置上的字母轉(zhuǎn)換為大寫 (若該位置上不是字母,則不轉(zhuǎn)換 )。 例如 , 若輸入 abc4EFg,則應(yīng)輸出 aBc4EFg。 注意 : 部分源程序存在文件 中。 請(qǐng)勿改動(dòng)主函數(shù) main 和其它函數(shù)中的任何內(nèi)容,僅在函數(shù) fun 的花括號(hào)中填入你編寫的若干語句。 給定源程序: include include void fun (char *ss) { } main() {char tt[81] 。 void NONO ()。 printf(\nPlease enter an string within 80 characters:\n)。 gets(tt)。 printf(\n\nAfter changing, the string\n \%s\, tt)。 fun(tt)。 printf(\nbees\n \%s\\n, tt)。 NONO ()。 } void NONO () {/* 本函數(shù)用于打開文件,輸入數(shù)據(jù),調(diào)用函數(shù),輸出數(shù)據(jù),關(guān)閉文件。 */ FILE *fp, *wf 。 char tt[81] 。 int i 。 fp = fopen(,r)。 wf = fopen(,w)。 for(i = 0 。 i 10 。 i++) { fscanf(fp, %s, tt)。 fun(tt)。 fprintf(wf, %s\n, tt)。 } fclose(fp)。 fclose(wf)。 } 參考答案: { int i 。 for(i = 1 。 i strlen(*ss) 。 i+=2) { if(ss[i] = 39。a39。 amp。amp。 ss[i] = 39。z39。) ss[i] = 32 。 } } 第 09 套: 一、填空題: 給定程序中 ,函數(shù) fun 的功能是 :統(tǒng)計(jì)出帶有頭結(jié)點(diǎn)的單向鏈表中結(jié)點(diǎn)的個(gè)數(shù) , 存放在形參 n 所指的存儲(chǔ)單元中。 請(qǐng)?jiān)诔绦虻南聞澗€處填入正確的內(nèi)容并把下劃線刪除,使程序得出正確的結(jié)果。 注意:源程序存放在考生文件夾的 中。 不得增行或刪行,也不得更改程序的結(jié)構(gòu)! 給定源程序: include include define N 8 typedef struct list {int data。 struct list *next。 } SLIST。 SLIST *creatlist(int *a)。 void outlist(SLIST *)。 void fun(SLIST *h, int *n) {SLIST *p。 /**********found**********/ ___1___=0。 p=hnext。 while(p) { (*n)++。 /**********found**********/ p=p___2___。 } } main() {SLIST *head。 int a[N]={12,87,45,32,91,16,20,48}, num。 head=creatlist(a)。 outlist(head)。 /**********found**********/ fun(___3___, amp。num)。 printf(\nnumber=%d\n,num)。 } SLIST *creatlist(int a[]) {SLIST *h,*p,*q。 int i。 h=p=(SLIST *)malloc(sizeof(SLIST))。 for(i=0。 iN。 i++) {q=(SLIST *)malloc(sizeof(SLIST))。 qdata=a[i]。 pnext=q。 p=q。 } pnext=0。 return h。 } void outlist(SLIST *h) {SLIST *p。 p=hnext。 if (p==NULL) printf(The list is NULL!\n)。 else {printf(\nHead )。 do {printf(%d,pdata)。 p=pnext。} while(p!=NULL)。 printf(End\n)。 } } 解題答案 : /**********第一空 **********/ *n=0。 /**********第二空 **********/ p=pnext。 /**********第三空 **********/ fun(head, amp。num)。 ****************************************** 二、改錯(cuò)題: 給定程序 中函數(shù) fun 的功能是:求出 s 所指字符串中最后一次出現(xiàn)的 t 所指子字符串的地址,通過函數(shù)值返回,在主函數(shù)中輸出從此地址開始的字符串 。 若未找 到,則函數(shù)值為 NULL。 例如,當(dāng)字符串中的內(nèi)容為: abcdabfabcdx, t 中的內(nèi)容為: ab時(shí),輸出結(jié)果應(yīng)是: abcdx。 當(dāng)字符串中的內(nèi)容為: abcdabfabcdx, t 中的內(nèi)容為: abd時(shí),則程序輸出未找到信息: not be found!。 請(qǐng)改正程序中的錯(cuò)誤,使它能得出正確的結(jié)果。 注意:不要改動(dòng) main 函數(shù),不得增行或刪行,也不得更改程序的結(jié)構(gòu)! 給定源程序: include include char * fun (char *s, char *t) { char *p , *r, *a。 /************found************/ a = Null。 while (*s) {p = s。 r = t。 while (*r) /************found************/ if (r == p) {r++。 p++。} else break。 if (*r == 39。\039。) a = s。 s++。 } return a 。 } main() { char s[100], t[100], *p。 printf(\nPlease enter string S :)。 scanf(%s, s)。 printf(\nPlease enter substring t :)。 scanf(%s, t)。 p = fun(s, t)。 if (p) printf(\nThe result is : %s\n, p)。 else printf(\nNot found !\n)。 } 解題答案 : /************found************/ a=NULL。 /************found************/ if(*r==*p) ****************************************** 三、程序題: 函數(shù) fun 的功能是: 將 s 所指字符串中除了下標(biāo)為偶數(shù)、同時(shí) ASCII 值也為偶數(shù)的字符外 ,其余的全都刪除;串中剩余字符所形成的一個(gè)新串放在 t 所指的數(shù)組中。 例如,若 s 所指字符串中的內(nèi)容為: ABCDEFG123456, 其中字符 A 的 ASCII 碼 值為奇數(shù),因此應(yīng)當(dāng)刪除;其中字符 B 的 ASCII 碼值為偶數(shù),但在數(shù)組中的下標(biāo)為奇數(shù),因此也應(yīng)當(dāng)刪除;而字符 2 的 ASCII 碼值為偶數(shù),所在數(shù)組中的下標(biāo)也為偶數(shù),因此不應(yīng)當(dāng)刪除,其它依此類
點(diǎn)擊復(fù)制文檔內(nèi)容
試題試卷相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1