请编一个函数void proc(int ttEM][N],int pp[N]),tt 指向一个M行N列的二维数组,求出二维数组每行中最大元素,并依次放入pp所指的一维数组中。二维数组中的数已在主函数中给出。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。 试题程序: include<stdio.h> include<conio.h> include<stdlib.h> define M 3 define N 4 void proc(int ttrM3rN]。int pp[N]) {
} void main { int str[M][N]={ {34,56,84,78}, {23,84,93,12), {28,38,39,93}}; int p[N],i,j,k; system("CLS"); printf("The riginal data is:\n"); for(i=0;i<M;i++) { for(j=0;j<N;j++) printf("%6d",str[i][j]); printf("\n"); } proc(str,p); printf("\nThe result is:\n");for(k=0:k<M;k++) printf("%4d",p[k]); printf("n");}
第1题
判别式(disc=b*b-4*a*c)小于0,则要求重新输入a、b、c的值。 例如,当a=1,b=2,c=1时,方程的两个根分别是:x1 =-1.00,x2=-1.00。 注意:部分源程序给出如下。 请勿改动函数中的其他任何内容,仅在横线上填入所编写的若干表达式或语旬。 试题程序: include<math.h》 include<stdio.h》 void main { double a,b,c,x1,x2,disc; do { printf("Input a,b,C:"); scanf("%1f,%1f,%1f”,&a,&b,&C); disc=b*b一4*a*C: if(disc<0) printf("disc=%1f\n Input again!\n",disc); } while(【1】); printf("****1he result****\n"); x1=(-b+【2】 (disc))/(2*a); x2=(-b-【3】(disc))/(2*a); printf("\nx1=%6.21f\nx2=%6.21f\n",x1,x2); }
第2题
数中输出。
例如,输入下面的矩阵: 其转置矩阵为:
1 2 3 1 4 7
4 5 6 2 5 8
7 8 9 3 6 9
程序输出:
2 6 10
6 10 14
10 14 18
注意:部分源程序在文件PROGl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
第3题
序后下标为奇数的字符取出,存入形参p所指字符数组中,形成一个新串。
例如,形参s所指的字符串为:baawrslkjghzlicda,执行后p所指字符数组中的字符串应为:aachjlsw。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANKl.C中。
不得增行或删行,也不得更改程序的结构!
第4题
次左移,原来左边的各列依次绕到右边。
例如,有下列矩阵:
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
若k为2,程序执行结果为
3 4 5 1 2
3 4 5 1 2
3 4 5 1 2
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANKl.C中。
不得增行或删行,也不得更改程序的结构!
第5题
盘文件中。请勿改动main函数与其他函数中的任何内容,仅在的横线上填写所需的若干表达式或语句。 注意:部分源程序给出如下。 试题程序: include<stdlib.h> include<stdio.h> define N 100 void main { FILE*f: int i=0: char ch; char s[N]="Welcome!"; if((f=fopenl("【1】","w"))==NULL) { printf("cannot open file.dat\n"); exit(0); } while(s[i]) { ch=s[i]; 【2】 ; putchar(ch); i++: } 【3】 ; }
第6题
数,并且逆序输出。结果由函数返回。例如,输入:1234567,结果输出:7654321。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填人所编写的若干表达式或语句。 试题程序: include<stdlib.h> include<conio.h> include stdio.h> include<string.h> unsigned long proc(char*str) { unsigned long t=0: int k: int i=0; i=str|en(str); for(【1】 ;i>=0;i--) { k= 【2】 ; t= 【3】 ; } return t; } void main { char str[8]; system("CLS"); printf("Enter a string made up of0to 9 digital character:\n"); gets(str); printf("The string,is:%s\n",str); if(strlen(str)>8) printf("The string is too tong!"); else printf("The result:%1u\n", proc(str)); }
第7题
整数1234,则应输出:2,617。 请修改程序中的错误,使程序能得出正确的结果。 注意:不要改动main函数,不能增选或删行,也不能匿改程序的结构。 试题程序: include<conio.h> include<stdio.h> //****found**** Prime(int m); { int j,P; p=1; //****found**** for(j=2;j<m;j++) if!(m%j) { p=0; break; } return(p);
int i,n; printf("\nplease enter an integer number between2 and 5000:"); scanf("%d",&n); printf("\n\nThe prime factor(s)of%d is(are):",n): for(i=2;i<n;i4+) if((!(n%i))&&(Prime(i))) printf("%4d,",i); printf("\n"); }
第8题
什么也不做,若不同,则将其插在串的最后。请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: include<stdlib.h> include<conio.h> include<stdio.h> include<string.h> //****found**** void proc(char str,char ch) { while(*str &&*str!=ch)str++; //****found**** if(*str==ch) { str[0]=ch; //****found**** str[1]=0: } } void main { char str[81],ch; system("CLS"); printf("\nPlease enter a string:"); gets(str); printf("\n Please enter the character to search:"); ch=getchar; proc(str,ch); printf("\nThe result is%s\n",str); }
第9题
,并将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。
请改正函数fun中指定部位的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
第10题
函数fun的功能是:计算
的前n项。若x=2.5,函数值为:12.182340。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANKl.C中。
不得增行或删行,也不得更改程序的结构!
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!