版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
TOC\o"1-1"\h\z\u【1.app 2mn1<=m<=6,1<=n<=6)a(mn列)中的元素,分別求出各行元和,并輸出。輸出使用語句:printf("sumofrowdis%d\n",i,3 sumofrow0issumofrow1is-sumofrow2is#include<stdio.h>intmain(void){inti,j,m,n,intfor(i=0;i<m;i++)for(j=0;j<n;j++)scanf("%d",&a[i][j]); printf("sumofrow%dis%d\n",i,}return}mnm≥1,n≤6)mna中的元素,a中的每個(gè)元素b。23(m=2,456123New645312#include<stdio.h>intmain(void){inta[6][6],b[6][6],i,j,m,for(i=0;i<m;i++)for(j=0;j<n;j++) }printf("Newarray:\n");for(i=0;i<m;i++)for(j=0;j<n;j++)}return}repeat(0<repeat<10)repeat1n(1≤n≤6),na,元和。副對(duì)角線為從矩陣的右上角至左下角的連線。 231sum= #include<stdio.h>intmain(void){inti,j,n,sum,b;intrepeat,ri;intscanf("%d",for(ri=1;ri<=repeat;ri++){scanf("%d",&n);for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",
printf("sum=%d\n",}return}repeat0<repeat<10)repeat次下列運(yùn)算:輸入一個(gè)正整數(shù)n(0<n<10)n×n項(xiàng)。 輸出*123112243369#include<stdio.h>intmain(void){inti,j,inta[10][10];intrepeat,for(ri=1;ri<=repeat;ri++){scanf("%d",&n); elseif(j==0)for(i=0;i<=n;i++){for(j=0;j<=n;if(i==0&&j==0)printf("%-4c",elseif(i==0||j<=i)printf("%-4d",a[i][j]);}}return}repeat(0<repeat<10)repeat輸入1個(gè)正整數(shù)n(1≤n≤6)和n階方陣a中的元素,如果a是上三角矩陣,"YES",否則,輸出"NO"上三角矩陣指主對(duì)角線以下的元素都為0的矩陣,主對(duì)角線為從矩陣的左上角至右下角 #include<stdio.h>intmain(void){intflag,i,j,n;inta[6][6];intrepeat,scanf("%d",for(ri=1;ri<=repeat;ri++){scanf("%d",&n);for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",
if(flag==0) }return}repeat0<repeat<10)repeat次下列運(yùn)算:,day)year、month和dayintint。19813 (198131日20003 (200031日Daysofyear: (19813160天Daysofyear: (20003161天#include<stdio.h>intmain(void){intday,day_year,month,year;intrepeat,ri;intday_of_year(intyear,intmonth,intscanf("%d",for(ri=1;ri<=repeat;ri++){scanf("%d%d%d",&year,&month,&day); day_year=day_of_year(year,month, printf("Daysofyear:%d\n",day_year);}return} intday_of_year(intyear,intmonth,int{intintreturnday;}(n≤612345700089 12345700089#include<stdio.h>intmain(void){inta[10][10],i,j,n,scanf("%d",&n);for(i=0;i<n;for(j=0;j<n;j++)
}}}}for(i=0;i<n;for(j=0;j<n;j++)printf("%5d",a[i][j]);}return}repeat(0<repeat<10)repeat1n(1≤n≤6)naa1個(gè)鞍點(diǎn),如果找到a的鞍點(diǎn),就輸出其下標(biāo),否則,輸出"NO"。鞍點(diǎn)的元素值在該行上最大,在該列上最小。 20 9214a[2][1]6#include"stdio.h"intmain(void){intflag,i,j,k,row,col,n;inta[6][6];intrepeat,scanf("%d",for(ri=1;ri<=repeat;ri++){scanf("%d",&n);for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",
}if(flag!=printf("a[%d][%d]=%d\n",row,}
return}輸入一個(gè)以回車結(jié)束的字符串(80個(gè)字符),將它的內(nèi)容逆序輸出。如"ABCD"的逆序
eto!uoyot#include<stdio.h>intmain(void){inti,k,temp;charstr[80];i=while((str[i]=getchar())!='\n')str[i]= for(i=0;str[i]!=0;return0;}輸入一個(gè)以回車結(jié)束的字符串(80個(gè)字符,把字符串中的所有數(shù)字字符('0~'9')轉(zhuǎn)#include<stdio.h>intmain(void){inti,char return0;}repeat0<repeat<10)repeat(下標(biāo)從0開始"NotFound"。 programming(字符串"programming") index=7 NotFound #include<stdio.h>#defineMAXLEN80intmain(void){charcc,charstr[MAXLEN];intcount,flag,i,index;intrepeat,ri;scanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){cc=getchar();i=while((ch=getchar())!='\n'){str[i++]=ch;}str[i]= if(flag!=printf("index=%d\n",}
printf("Notreturn}repeat(0<repeat<10)repeat寫輔音字母:除'A','E','I','O','U'以外的大寫字母。 count=3 O"中有3個(gè)大寫輔音字母)count=0 #include<stdio.h>#defineMAXLEN80intmain(void){charcharstr[MAXLEN];intcount,i;intrepeat,scanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){i=0;while((ch=getchar())!='\n'){}str[i]= printf("count=%d\n",}return}repeat(0<repeat<10)repeat原字 AflagofUSAAfterreced:ZflagofFHZAfterreced:1+2=3#include<stdio.h>#include<string.h>#defineMAXLEN80intmain(void){charcharstr[MAXLEN];inti;intrepeat,scanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){i=0;while((ch=getchar())!='\n'){str[i]=ch;}str[i]= printf("Afterreced:");for(i=0;str[i]!=0;i++)}return}大寫英文字母則輸出“NotFoundFONTNAMEandFILENAMEfontnameandNotintmain(void){charstr[80],newstr[80];inti,j,k,ri,repeat;scanf("%d",&repeat);for(ri=1;ri<=repeat;while((str[i]=getchar())!='\n') }printf("Not
for(i=0;newstr[i]!='\0';i++)}return}輸入一個(gè)以回車結(jié)束的字符串(80個(gè)字符ASCII碼intmain(void){charstr[80],ch;inti=0,j,k;while((str[i]=getchar())!='\n')str[i]= for(i=0;str[i]!='\0';return0;}repeat(0<repeat<10)repeat1010 A#include<stdio.h>intmain(void){intx,base,i,k,y;intri,repeat;charscanf("%d",for(ri=1;ri<=repeat;ri++{ }return}repeat(0<repeat<10)repeat programming(字符串 (字符 count2('m'在"programming"2次)count=0('a'在"1234"中沒有出現(xiàn)過)#include"stdio.h"#defineMAXLEN80intmain(void){charcc,charstr[MAXLEN];inti,count;intrepeat,scanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){i=0;while((str[i]=getchar())!='\n')str[i]=0;cc=getchar(); printf("count=%d\n",}return}repeat0<repeat<10)repeat次下列運(yùn)算:輸入一個(gè)正整數(shù)n(0<n<10),輸出三角形的前n行。 11111 1111 #include<stdio.h>intmain(void){inti,j,n,repeat,ri;inta[10][10]; }}return}3先輸入學(xué)生的人數(shù)(<30人(提示:定義一個(gè)score[30][5]數(shù)組,score[0]、score[1]、score[2]分別3門課程的分?jǐn)?shù)score[3]、score[4]分別每個(gè)學(xué)生的總分和平均分total和avg3門課程的總分和平均分。) 788794(1個(gè)學(xué)生的成績(jī)808080(2個(gè)學(xué)生的成績(jī)767677(3個(gè)學(xué)生的成績(jī)588766(4個(gè)學(xué)生的成績(jī)898788(5個(gè)學(xué)生的成績(jī))總分平均分#include<stdio.h>intmain(void){intavg[3],score[30][5],total[3];inti,j,n;for{} 枃 枃{
鏁板鑻辮鎬誨 騫沖潎鍒哱} printf("\n騫沖潎鍒?");return}repeat(0<repeat<10)repeatDec=Dec=#include"stdio.h"#include"string.h"#defineMAXLEN80intmain(void){charcharstr[MAXLEN],num[MAXLEN];inti,k;intrepeat,ri;longscanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){i=0;while((ch=getchar())!='\n'){}str[i]= printf("Dec=}return}repeat(0<repeat<10)repeatx和y,并通過指針運(yùn)算找出兩個(gè)數(shù)中的最大值,輸出到屏幕上。 (x=3,max=#include<stdio.h>intmain(void){intmax,x,y,*pmax,*px, printf("max=return}nm(1<m<n<=10)n個(gè)整數(shù),將這些數(shù)排成一行,向右循環(huán)移動(dòng)m個(gè)位置(從右邊移出的數(shù)再?gòu)淖筮呉迫雗個(gè)整數(shù)。mov(x,n,m)x的類型是整型指針,nmintvoid。5 1234 (5個(gè)整數(shù)Aftermoved:3451#includevoidmov(int*x,intn,intm);intmain(void){inti,m,intscanf("%d%d",&n,&m);for(i=0;i<n;i++)scanf("%d", printf("Aftermoved:");for(i=0;i<n;i++)printf("%d",a[i]);return} 輸入兩個(gè)實(shí)數(shù)a和b,要求定義并調(diào)用函數(shù)sum_diff(floatop1,floatop2,floatvoidmain4-2-0.75Thesumis10.00Thediffis-2.00Thesumis-6.00Thediffis2.00Thesumis1.00Thediffis0.50#includevoidsum_diff(floatop1,floatop2,float*psum,float*pdiff);intmain(void){floata,b,sum,diff;intri,repeat;scanf("%d",for(ri=1;ri<=repeat;ri++){scanf("%f%f",&a,&b); printf("Thesumis%.2f\nThediffis}return} repeat(0<repeat<10)repeatn1<n<=10)naa中的元sort(a,n)an個(gè)元素anint,函數(shù)的類型void。517 125432Aftersortedthearrayis:156Aftersortedthearrayis:12Aftersortedthearrayis:1234#include<stdio.h>voidsort(inta[],intn);intmain(void){inti,intrepeat,intscanf("%d",for(ri=1;ri<=repeat;ri++){scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&a[i]); printf("Aftersortedthearrayis:");for(i=0;i<n;i++)printf("%d",a[i]);}return} repeat0<repeat<10)repeatn(1<n<=10)nax,在數(shù)a中查找x,如果找到則輸出相應(yīng)元素的最小下標(biāo),否則輸出"Notfound"。search(list,n,x)listx,若找到則返回相應(yīng)元素的最小下標(biāo),否則返回-1listnx的類型intvoid。12- 1225 index=1Notfound#include<stdio.h>intmain(void){inti,index,n,res,x;intrepeat,ri;intintsearch(intlist[],intn,intscanf("%d",for(ri=1;ri<=repeat;ri++){scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&a[i]);scanf("%d", if(res!=-printf("index=%d\n",}
printf("Notreturn} 輸入一個(gè)正整數(shù)n(1<n<=50,有n個(gè)人圍成一圈,按順序從1到n編好號(hào)。從第一個(gè)人開始報(bào)數(shù),報(bào)到3的人退出圈子,下一個(gè)人從1開始重?cái)?shù),報(bào)到3的人退出圈子。0的數(shù),該數(shù)就是最后一個(gè)人的編號(hào)。輸出使用語句:printf("No%d:d\n",no (n個(gè)人報(bào)數(shù),n=5)LastNois: intmain(void){intcount,i,n,no;intnum[50];intscanf("%d",&n);for(i=0;i<n;num[i]=i+1;p=num; p=num;while(*p==0)printf("LastNois:%d\n",*p);return0;}5個(gè)字符串,輸出其中最小的字符串。Minis:Jin*/#include<stdio.h>#include<string.h>intmain(void){ min[80],str[80];inti;scanf("%s", printf("Minis:%s\n",min);return0;}repeat(0<repeat<10)repeatststrcstrcst的尾部。HappyBirthday#includevoidstrc(char*s,char*t);intmain(void){charreturn} repeat(0<repeat<10)repeat5scanf("%s",sx);redbluegreenyellowThelongestis:zhangThelongestis:#include<stdio.h>#include<string.h>intmain(void){charsx[80],longest[80];inti;intrepeat,scanf("%d",for(ri=1;ri<=repeat;ri++){scanf("%s",sx); return}repeat(0<repeat<10)repeat輸入一個(gè)字符串t和一個(gè)正整數(shù)m,將字符串t中從第m個(gè)字符開始的全部字符到字符串s中,再輸出字符串s。要求定義并調(diào)用函數(shù)strmcpy(s,t,m),它的功能是將字符串t中從第m個(gè)字符開始的全部字符到字符串s中,函數(shù)形參s和t的類型是字符指針,形參m的類型是int,函數(shù)類void。happynewyearOutputis:newyear (從"happynewyear"第7個(gè)字符開始組成的新字符串為"newOutputis: (從"happy"1個(gè)字符開始組成的新字符串為error intmain(void){chars[80],t[80];intm;intrepeat,voidstrmcpy(char*s,char*t,intscanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){scanf("%d",&m);if(strlen(t)<m)printf("errorinput\n"); printf("Outputis:}}return} bFaE3+8=1R大寫字母數(shù)為:小寫字母數(shù)為:空格為:數(shù)字為:其他字符為:intmain(void){chars[80];char*p;intblank,digit,lower,other,upper=lower=blank=digit=other= printf("澶у啓瀛楁瘝鏁頒負(fù):%d\n灝忓啓瀛楁瘝鏁頒負(fù):%d\n絀烘牸涓?%d\n涓d\n鍏朵粬瀛楃涓d\n",upperlowerblank,digit,other);return0;}/*3個(gè)字母移到最后,輸出變換后的字符串。#include<stdio.h>#include<stdlib.h>#include#defineMAXLINE100intmain(void){charline[MAXLINE],str[4];inti;if(strlen(line)<3)printf("瀛楃涓查暱搴﹀皬浜?n");} printf("%s\n",line);return0;}’或者’DAD123456789DAftersorted:1098765432#includevoidsortAsc(inta[],intn);voidsortDesc(inta[],intn);intmain(void){inti,n,a[10];charc;for(i=0;i<n;i++)scanf("%d",&a[i]);if(c=='A')sortAsc(a,n);elseif(c=='D')else{printf("theinputcharisnot'A'or'D'!,programisclosed");}printf("Aftersorted:");for(i=0;i<n;i++)printf("%d",a[i]);return} /*5個(gè)字符串,按由小到大的順序輸出。redyellowbluegreenAftersorted:#include<stdio.h>#include<string.h>intmain(void){inti,j,charsx[5][80],stemp[80];scanf("%s", printf("Aftersorted:\n");for(i=0;i<5;i++)return0;}/*repeat0<repeat<10)repeat輸入兩個(gè)字符串,調(diào)用函 p(s1,s2),實(shí)現(xiàn)兩個(gè)字符串的比較,返回值分別為1、0-1s1>s2,s1=s2,s1<s2的情況。30#include p(char*s1,char*s2);intmain(void){intresult,ri,repeat;chars1[80],scanf("%d",&repeat);for(ri=1;ri<=repeat;{p(s1,s2);printf("%d\n",result);}return} /*repeat0<repeat<10)repeat次下列運(yùn)算:findstr(char*str,char*substr)2mkloas6。 asdasasdfgasdaszx67asd am123am456amam 65#include"stdio.h"intmain(void){
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 天府新區(qū)信息職業(yè)學(xué)院《世界經(jīng)典建筑解析》2023-2024學(xué)年第一學(xué)期期末試卷
- 公司裝修發(fā)票合同范例
- 系統(tǒng)訓(xùn)練幼兒體能課程設(shè)計(jì)
- 到貨合同范例
- 單位電路施工合同范例
- 農(nóng)機(jī)合伙合同范例
- 縣衙漢服租借合同范例
- 第六章 愛護(hù)植被,綠化祖國(guó)教學(xué)實(shí)錄 2023-2024學(xué)年人教版生物七年級(jí)上冊(cè)
- 中介廠區(qū)駐廠合同范例
- 單位寫合同范例
- 2023年大連國(guó)際機(jī)場(chǎng)股份有限公司招聘筆試題庫(kù)及答案解析
- 國(guó)內(nèi)外油氣管道技術(shù)現(xiàn)狀與發(fā)展趨勢(shì)課件
- 衛(wèi)生監(jiān)督協(xié)管醫(yī)療監(jiān)督檢查培訓(xùn)課件
- 內(nèi)蒙古農(nóng)業(yè)大學(xué)會(huì)計(jì)學(xué)基礎(chǔ)期末提高試卷
- 監(jiān)控立桿規(guī)格及施工規(guī)范
- 2.軟件著作權(quán)-操作手冊(cè)編寫示例
- 行政管理專業(yè)公共政策學(xué)課程大綱
- 江蘇省無錫市各縣區(qū)鄉(xiāng)鎮(zhèn)行政村村莊村名居民村民委員會(huì)明細(xì)
- 可逆性胼胝體壓部綜合癥培訓(xùn)課件
- 國(guó)家開放大學(xué)《可編程控制器應(yīng)用實(shí)訓(xùn)》形考任務(wù)4(實(shí)訓(xùn)四)
- 寵物店洗護(hù)免責(zé)協(xié)議書
評(píng)論
0/150
提交評(píng)論