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

正文內(nèi)容

c語(yǔ)言程序設(shè)計(jì)習(xí)題集(參考版)

2025-03-07 16:34本頁(yè)面
  

【正文】 fclose(fp)。i++) if(fwrite(amp。 for(i=0。 } stu[i].avr=sum/。stu[i].score[j])。j++) { printf(score %d.,j+1)。 for(j=0。 scanf(%s,stu[i].name)。 scanf(%s,stu[i].num)。i++) { printf(\n please input No. %d score:\n,i)。 /*input*/ for(i=0。 main() {int i,j,sum。 float avr。 char name[8]。 } 有五個(gè)學(xué)生,每個(gè)學(xué)生有 3門(mén)課的成績(jī),從鍵盤(pán)輸入以上數(shù)據(jù)(包括學(xué)生號(hào),姓名,三門(mén)課成績(jī)),計(jì)算出 平均成績(jī),況原有的數(shù)據(jù)和計(jì)算出的平均分?jǐn)?shù)存放在磁盤(pán)文件 stud中。 printf(%s\n,str)。 fp=fopen(test,r)。 i++。) 26 str[i]=str[i]32。str[i]=39。amp。) { if(str[i]=39。 while(str[i]!=39。} printf(please input a string:\n)。 if((fp=fopen(test,w))==NULL) { printf(cannot open the file\n)。 char str[100],filename[10]。 輸入的字符串以!結(jié)束。 } getch()。 while(head_out!=NULL) { printf(“%d”,head_outno)。 head_out=josphus(head,7,2,5)。 } void main() {struct node *head,*head_out。pnext=NULL。 else p=pnext。 if(p==head) head=headnext。 else tail_outnext=p。 num++。p=pnext。p=head。countm。 /*報(bào)數(shù)出列 */ while(num=n1) { /*從 S開(kāi)始報(bào)數(shù),報(bào)到 m的人出列 */ count=1。count++) prior=p。 for(count=1。 /*查找開(kāi)始位置 */ p=head。 */ struct node *josephus(struct node *head,int n,int s,int m) { struct node *p,*prior,*head_out,*tail_out。 } return(head)。/*是第一個(gè)結(jié)點(diǎn)則置頭指針 */ else tailnext=new。 /*,并設(shè)置新的尾指針 */ newnext=NULL。break。newno)。/*申請(qǐng) 1個(gè)新結(jié)點(diǎn)空間 */ /* */ printf(“輸入第 %d個(gè)數(shù): ”,count+1)。 /*鏈表結(jié)點(diǎn)個(gè)數(shù) */ for(。 /*指針域 */ } /*create()函數(shù),創(chuàng)建一個(gè)單鏈表,返回單鏈表的頭指針 */ struct node *create(void) { struct node *head=NULL,*new,*tail。 Josephus 問(wèn)題是:對(duì)于任意給定的 n、 s 和 m(sn,mn),按出列順序得到的順序表如何? 解:參考源程序 : define NULL 0 idefine LEN sizeof(struct node)/*定義結(jié)點(diǎn)長(zhǎng)度 */ /*定義結(jié)點(diǎn)結(jié)構(gòu) */ Struct node { int no。 } 編寫(xiě)一個(gè)程序,使用單鏈表作數(shù)據(jù)結(jié)構(gòu),解決 Josephus問(wèn)題。 printf(“分?jǐn)?shù): %s\n”,stu[max].score)。 printf(“學(xué)號(hào): %s\n”,stu[max].no)。 } /*輸出平均成績(jī)和最高成績(jī)學(xué)生的信息 */ printf(“\naverage=%.2f\n”,(float)sum/NUM)。 /*計(jì)算總成績(jī),查找最高成績(jī)學(xué)生 */ sum+=stu[count].score。 printf(“ name:”)。 printf(“ no(format:99999):”)。countNum。 int count,max=0,sum=0。 }。 解:參考源程序: define NUM 5 include “” /*定義學(xué)生信息結(jié)構(gòu)類(lèi)型 */ struct students { char no[7],name[9]。 } 某學(xué)習(xí)小組有 5 個(gè)人,每個(gè)人的信息包括:學(xué)號(hào)、姓名和成績(jī)。 /*處理 2月份的天數(shù) */ If(month2) sum+=leap()。month++) Sum+=days[month]。 /*計(jì)算天數(shù) */ For(month=1,sum=0。,amp。 Scanf(“%d,%d,%d”,amp。 int month,sum。 } /*主函數(shù) */ main() { int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}。y%100!=0||y%400==0) flag=1。 if(y%4==0amp。 解:參考源程序: /*定義日期結(jié)構(gòu)類(lèi)型 */ struct date {int year,month,day。 else printf(“輸入錯(cuò)誤 !”)。amp。month)。 printf(“請(qǐng)輸入月份數(shù): ”)。 printf(“%d月的英文名稱(chēng)是: %s\n”,month,*(english+month1))。 } 使用指針數(shù)組,編寫(xiě)一個(gè)通用的英文月份名顯示函數(shù) void display(int month)。i=N。} p++。i=0。 if(*p!=0) i++。k!=1。k=N。i++,p++) *p=i。 for(i=0,p=a。從第 1個(gè)人開(kāi)始報(bào)數(shù)(從 1到 3報(bào)數(shù)),凡報(bào)到 3 的人退出圈子,問(wèn)最后留下的是原來(lái)的第幾號(hào)的那位。 printf(\n)。u10。 f(a,10)。u++) scanf(%d,amp。 for(u=0。 return。*p1=x[0]。x[n1]=t。} } t=*p0。p1=amp。x[y]。y++) { if(x[y]i) {i=x[y]。 for(y=0。 i=j=x[0]。 解:參考源程序: void f(x,n) {int x[],n。 } 輸入 10個(gè)整數(shù),將其中最小的數(shù)與第一個(gè)數(shù)對(duì)換,把最大的數(shù)與最后一個(gè)數(shù)對(duì)換。pq+N。strcpy(q+2,q+1)。 if(n0) {strcpy(str1,q)。strcpy(q+2,str1)。 if(m0) {strcpy(str1,q)。strcpy(q+1,str1)。 21 if(l0) {strcpy(str1,q)。p++) gets(p)。 for(。 int i,l,m,n。} printf(%d,%d,%d\n,a,b,c)。*p2=*p3。*p3=t。} if(ac) {t=*p1。*p1=*p2。c。b。a。c)。a,amp。 } 或 main() {int a,b,c,*p1,*p2,*p3,t。p3=t。} if(*p2*p3) {t=p2。p1=p3。p2=t。 if(*p1*p2) {t=p1。p3=amp。p2=amp。 p1=amp。b,amp。 scanf(%d,%d,%d,amp。 } 第 9章 指針 輸入三個(gè)整數(shù),按由小到大的順序輸出。 if(LEAPYEAR(y)) printf(%d is a not leap year\n,y)。 scanf(%d,amp。amp。提示:宏名可以定義為 LEAP_YEAR,形參為 y。 printf(s=%.3f area=%.3f\n,s,area)。 s=SSS(a,b,c)。b,amp。 scanf(%f %f %f,amp。寫(xiě)程序,在程序中用帶實(shí)參的宏名來(lái)求面積 area。 } 三角形面積為:三角形的面積 公式為: Area= ))()(( csbsass ??? 其中 S=(a+b+c)/2。 t=Q(c,d)。c,amp。 define Q(a,b) a%b main() {int c,d,t。 } ,求他們相除的余數(shù)。 CHANGE(c,d,s)。c,amp。b=a main() {int c,d,s。 解:參考源程序: define CHANGE(a,b,t) t=a。 } 第 8章 編譯預(yù)處理 ,使兩個(gè)參數(shù)的值互換,并寫(xiě)出程序,輸入兩個(gè)數(shù)作為使用宏時(shí)的實(shí)參。 printf(“ 一元三次方程為: %^3+%^2+%+%=0\n” ,a,b,c,d)。c,amp。a,amp。 printf(“ 請(qǐng)輸入一元三次方程的系數(shù) a,b,c,c:\n” )。 return(x)。 x=x0f/f1。 f=((a*x0+b)*x0+c)*x0+d。 參考源程序: include float solut(float a,float b,float c,float d) { float x=1,x0,f,f1。 } } 用函數(shù)實(shí)現(xiàn)牛頓迭代法求一元三次方程的根。j++) printf(%7d,array[i][j])。i++) {for(j=0。 for(i=0。 } fun(array)。j++) printf(%7d,array[i][j])。i++) {for(j=0。 for(i=0。 int array[3][3]={{100,200,300},{400,500,600},{700,800,900}}。array[j][i]=t。j++) {t=array[i][j]。i++) for(j=i+1。 for(i=0。j++)來(lái)完成左上角的走動(dòng)。i++)再套 for(j=i+1。 18 解:程序分析 這題的關(guān)鍵 在于進(jìn)行行列下標(biāo)轉(zhuǎn)換的算法,由矩陣的對(duì)稱(chēng)性我們不難看出在進(jìn)行行列互換時(shí) a[j]在好是與a[j][i]互換,因而只要我位讓程序走完矩陣的左上角即可(用 for(i=0。 printf(%s\n,s1)。 fun(s1,s2)。 printf(s2=%s\n,s2)。 scanf(%s%s,s1,s2)。 clrscr()。\039。j++) p1[i++]=p2[j]。i++) for(j=0。 for(i=0。 } 編寫(xiě)一個(gè)函數(shù)實(shí)現(xiàn)兩個(gè)字符 串的連接(不使用庫(kù)函數(shù) strcat())。 printf(The string after modified:)。 fun(a)。 printf(The original string is:)。 printf(Enter a string:)。} } main() { char a[N]。*(s+i)=*(s+n1i)。s+is+n1i。即先進(jìn)行取內(nèi)容運(yùn)算 *) 參考源程序: include include define N 81 fun(char *s) 17 { int i=0,t,n=strlen(s)。 解:程序分析:該題的算法是先分別找出字符串的兩頭,然后同時(shí)逐一往中間移動(dòng),每移動(dòng)一次都進(jìn)行兩字符的位置對(duì)換,直到中間字符(用 s+is+n1i來(lái)控制)。 } fun(char
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1