题目内容 (请给出正确答案)
[主观题]

请编一个函数void proc(int ttEM][N],int pp[N]),tt 指向一个M行N列的二维数组,求出二维数组每

请编一个函数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");}

提问人:网友passoffice 发布时间:2022-01-06
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“请编一个函数void proc(int ttEM][N],i…”相关的问题
第1题
请编写一个函数proc,它的功能是:求出1~m(含m) 能被7或11整除的所有整数放在数组a中,通过n返回这

请编写一个函数proc,它的功能是:求出1~m(含m) 能被7或11整除的所有整数放在数组a中,通过n返回这些数的个数。 例如,若传给m的值为70,则程序输出: 7 11 14 21 22 28 33 35 42 44 49 55 56 63 66 70 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填人所编写的若干语句。 试题程序: include<stdlib.h> include<conio.h> include<stdio.h> define N 100 void proc(int m,int*a,int*n) {

} void main { int arr[N],n,k; system("CLS"); proc(70,arr,&n); for(k=0;k<n;k++) if((k+1)%20==0)//每行输出20个数 { printf("%4d",arr[k]); printf("\n"); } else printf("%4d",arr[k]); printf("\n"); }

点击查看答案
第2题
str是一个由数字和字母字符组成的字符串,由变量num传人字符串长度。请补充函数proc,该函数的功能
是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。 例如,str="abcl23de45f967",结果为:l234567。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。 试题程序: include<stdio.h> define M 80 int bb[M]; int proc(char str[],int bb[],int num) { int i,n=0; for(i=0;i<num;i++) { if(【1】 ) { bb[n]=【2】 ; n++; } } return 【3】 ; } void main { char str[M]; int num=0,n,i; printf("Enter a string:\n"); gets(str); while(str[num]) num++: n=proc(str,bb,num); printf("\nbb="); for(i=0;i<n;i++) printf("%d",bb[i]); }

点击查看答案
第3题
str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数proc,该函数的功能
是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。

例如,str="abc3de987f9621",结果为:3987621。

注意:部分源程序给出如下。

请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。

试题程序:

include<stdio.h>

define M 80

int bb[M];

int proc(char str[],int bb[],int num)

{

int i,n=0;

for(i=0;i<num;i++)

{

if(【1】)

{

bb[n]=【2】:

n++:

}

}

return 【3】 ;

}

void main

{

char str[M];

int mum=0,n,i;

printf("Enter a strin9:\n");

gets(str);

while(str[num])

num++:

n=proc(str,bb,num);

printf("\nbb=");

for(i=0;i<n;i++)

printf("%d",bb[i]);

}

点击查看答案
第4题
请编一个函数fun(oh lr*str),该函数的功能是把字符串中的内容逆置。 例如,字符串中原有的字符串为

请编一个函数fun(oh lr*str),该函数的功能是把字符串中的内容逆置。 例如,字符串中原有的字符串为asdf9,则调用该函数后,串中的内容为9fdsa。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填人所编写的若干语句。 试题程序: include<string.h> include<conio.h> include<stdio.h> define N 100 void fun(char * str) { } void main { char a[N]; FILE*out: printf("Enter a string:"); gets(a); printf("The origir al string is:"); puts(a); fun(a): printf("The string after modified:"); puts(a); strcpy(a,"Welcome!"); fun(a); ut=fopen("outfile.dat","w"); fprintf(out,"%s".a); fclose(out); }

点击查看答案
第5题
请补充函数proc,函数proc的功能是求7的阶乘。 注意:部分源程序给出如下。 请勿改动main函数和其
他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。 试题程序: include<stdio.h> long proc(int n) { if(【1】 ) return(n*proc(【2】 ); else if(【3】) return l; } void main { int k=7: printf("%d!=%ld\n",k,proc(k)); }

点击查看答案
第6题
编写一个函数,从传人的M个字符中找出最长的一个字符串,并通过形参指针max传回该串地址(用****作

编写一个函数,从传人的M个字符中找出最长的一个字符串,并通过形参指针max传回该串地址(用****作为结束输入的标志)。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填人所编写的若干语句。 试题程序: include<stdio.h> include<string.h> include<conio.h> char*proc(char(*a)[81],int num) { } void main { char ss[l0][81],*max; int n,i=0; printf("输入若干个字符串:"); gets(ss[i]); puts(ss[i]); while(!strcmp(ss[i],"****")= =0) { i++: gets(ssEi]); puts(ss[i]); } n=i: max=proe(SS,n); printf("\nmax=%s\n",max); }

点击查看答案
第7题
已知一个数列从0项开始的前3项为0,0,1,以后的各项都是其相邻的前3项之和。下列给定的程序中,函数p
roc 的功能是:计算并输出该数列前n项的和sum。n的值通过形参传人。例如,当n=20时,程序的输出结果应为42762.000000。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动maiil函数,不得增行或删行,也不得更改程序的结构。 试题程序: include<stdlib.h> include<conio.h> include<stdio.h> double proc(int n) { double sum,s0,s1,s2,s; int k; sum=1.0; if(n<=2) sum=0.0; s0=0.0; s1=0.0; s2=1.0; //****found**** for(k=4;k<n;k++) } { s=s0+s1+s2; sum+=S: s0=s1; s1=s2; //****found**** s2=s; return sum; } void main { int n; system("CLS"); printf("Input N="); scanf("%d",&n J; printf("%f\n",proc(n)); }

点击查看答案
第8题
程序输出结果为() #include <stdio.h> void proc (); int main () { int x=1; //定义局部变量x,局部变量只在本函数中有效 proc(); printf("%d\n",x); } void proc () { int x; //定义局部变量x,局部变量只在本函数中有效 x=2; }

A.1

B.2

C.main,proc函数中都定义了变量x,程序错误

D.0

点击查看答案
第9题
程序输出结果为()。 #include <stdio.h> int x=0; //x定义在所有函数之外,为全局变量 void proc (); int main () { x=1; proc(); printf("%d\n",x); } void proc () { x=2; }

A.2

B.0

C.1

D.程序错误

点击查看答案
第10题
请补充函数proc,该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字
符串所包含的指定字符的个数是奇数,则不删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,str指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。例如,当str输入“abcabcabcab”,c=b时,b的输出为“abcabcaca”;如果str的输入为“abcabcabca”,则b的输出为“abcabcabca”。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅程函数prOC的横线上填入所编写的若干表达式或语句。 试题程序: include<stdlib.h> include<stdio.h> include<conio.h> define M 80 void proc(char str[],char b[],char c) { int i=0,j=0; int n=0: int m=0: while(str[i]!=\0) { if(str[i]==c) n++: i++: } 【1】 ; if(n%2) { while(str[j]!=\0 ) { b[j]=str[j]; j++; } b[j]=\0; } else { while(str[i]!=\0 ) { b[j++]=str[i]; if(str[i]==c) m++: if((m>n/2)&&(str[i]==c)) 【2】 ; i++: } 【3】 ; } } void main { char str[M],b[M]; char C; system("CLS"); printf("Enter the strin9:\n"); gets(str); printf("Enter the character of the string deleted:"): scanf("%C",&c); proc(str,b,c); printf("The new string is:%s\n",b); }

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信