题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-08 19:14:34

[填空题]给定程序中,函数fun的功能是:判定形参a所指的NxN(规定N为奇数)的矩阵是否是“幻方”,若是,则函数返回值为1;若不是,则函数返回值为0。“幻方”的判定条件是:矩阵每行、每列、主对角线及反对角线上元素之和都相等。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#define N 3
int fun (int(+a)[N])
int i, j, m1, m2, row, colum;
m1=m2=0;
for(i=0; i<N; i++)
j=N-i-1; m1+=a[i][i];
m2+=a[i][j];
if(m1!=m2) return 0;
for(i=0; i<N; i++)
/******************found*******************/
row=colum= (1) ;
for(j=0; j<N; j++)
row+=a[i][j]; colum+=a[j][i];
/******************found*******************/
if(row!=colum) (2) (row!=m1)) return 0;

/******************found*******************/
return (3) ;

main( )
int x[N][N], i, j;
printf("Enter number for array:/n");
for(i=0; i<N; i++)
for(j=0; j<N; j++)
scanf("%d", &x[i][j]);
printf("Array:/n");
for(i=0; i<N; i++)
for(

更多"给定程序中,函数fun的功能是:判定形参a所指的NxN(规定N为奇数)"的相关试题:

[填空题]给定程序中,函数fun的功能是:判定形参a所指的NxN(规定N为奇数)的矩阵是否是“幻方”,若是,则函数返回值为1;若不是,则函数返回值为0。“幻方”的判定条件是:矩阵每行、每列、主对角线及反对角线上元素之和都相等。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#define N 3
int fun (int(+a)[N])
int i, j, m1, m2, row, colum;
m1=m2=0;
for(i=0; i<N; i++)
j=N-i-1; m1+=a[i][i];
m2+=a[i][j];
if(m1!=m2) return 0;
for(i=0; i<N; i++)
/******************found*******************/
row=colum= (1) ;
for(j=0; j<N; j++)
row+=a[i][j]; colum+=a[j][i];
/******************found*******************/
if(row!=colum) (2) (row!=m1)) return 0;

/******************found*******************/
return (3) ;

main( )
int x[N][N], i, j;
printf("Enter number for array:/n");
for(i=0; i<N; i++)
for(j=0; j<N; j++)
scanf("%d", &x[i][j]);
printf("Array:/n");
for(i=0; i<N; i++)
for(
[简答题]下列给定程序中函数fun的功能是:统计substr所指的字符串在str所指的字符串中出现的次数。 例如,若字符串为aass 1kaaas,子字符串为as,则应输出2。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构! 试题程序: #include <stdio.h> int fun(char *str, char *substr) { int i, j, k, num=0; /********** found**********/ for(i=0, str[i], i++) for(j=i, k=0; substr[k]==str[j]; k++, j++) /********** found**********/ If(substr[k+1]==’/0’) { num++; break; } return num; } main( ) { char str[80], substr[80]; printf("Input a string:"); gets(str); printf("Input a substfing: "); gets(substr); printf("%d/n", fun(str, substr)); }
[简答题]给定程序中函数fun的功能是:首先把b所指字符串中的字符按逆序存放,然后将a所指字符串中的字符和b所指字符串中的字符,按排列的顺序交叉合并到c所指数组中,过长的剩余字符接在c所指的数组的尾部。例如,当a所指字符串中的内容为“abcdefg”,b所指字符串中的内容为“1234”时,c所指数组中的内容应“a4b3c2dlefg”;而当a所指字符串中的内容为“1234”,b所指字符串的内容为“abcdefg”时,c所指数组中的内容应该为“lg2f3e4dcba”。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
void fun (char*a, char*, char *c)

inti, j; char ch;
i=0; j=strlen(b)-1;
/******************found*******************/
while(i>j)
ch=b[i]; b[i]=b[j]; b[j]=ch;
i++; j--;

while (*a|| *b)
/******************found*******************/
If(*a)
*c=*a; c++; a++;
if(*b)
*c=*b; c++; b++;

*c=0;

main( )

char s1[100], s2[100], t[200];
printf("/nEnter s1 string:"); scanf("%s", s1);
printf("/nEnter s2 string:"); scanf("%s", s2);
fun(s1, s2, t);
printf("/nThe result is: %s/n", t);

[填空题]下列给定程序中,函数fun( )的功能是:计算s所指字符串中含有t所指字符串的数目,并作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <string.h>
#include <stdio.h>
#define N 80
int fun(char *s,char *t)
int n;
char *p, *r;
n=0;
while(*s)
p=s;
/**************found***************/
r=p;
while(*r)
if*r==*p) r++; p++;
else break;
/**************found***************/
if(*r==0)
n++;
s++;

return n;

main( )
char a[N],b[N]; int m;
clrscr( );
printf("/nPlease enter string a:");
gets(a);
printf("/nPlease enter substring b:");
gets(b);
m=funa,b);
printf("/nThe result is :m=%d/n",m);

[填空题]下列给定程序中,函数fun( )的功能是:从s所指字符串中,找出t所指字符串的个数作为函数值返回。例如,当s所指字符串中的内容为abcdabfab,t所指字符串的内容为ab,则函数返回整数3。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构. 试题程序: #include <conio.h> #include <stdio.h> #include <string.h> int fun (char *s, char *t) {int n; char *p, *r; n=0; while(*s) {p=s; r=t; while (*r) /**************found**************/ if(*r==*p) {r++; p++} else break; /*************found**************/ if(r==’/0’) n++; s++; } return n; } main( ) {char s[100], t[100]; int m; clrscr( ); printf("/nPlease enter string s: "); scanf ("%s",s); printf("/nPlease enter substring t: "); scanf ("%s",t); m=fun (s,t); printf("/nThe result is: m=%d/n", m); }
[简答题]下列给定程序中,函数fun的功能是:统计形参s所指的字符串中数字字符出现的次数,并存放在形参c所指的变量中,最后在主函数中输出。
例如, 若形参s所指的字符串为“abcdef35adah3kjsdf7”,则输出结果为4。
请在下划线处填入正确内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(char*s,int*t)

int i,n;
n=0;
/********found********/
for(i=0; (1) =0;i++)
/********found********/
if(s[il>=’0’&&s[i]<= (2) )n++;
/********found********/
(3)

main( )

char s[80]="abcdef35adgh3kjsdf7";
int t;
printf("/nThe original string is:%s/n",s);
fun(s,&t);
printf("/nThe result is:%d/n"t);

[填空题]下列给定程序中,函数fun的功能是:在形参ss所指字符串数组中查找与形参t所指字符串相同的串,找到后返回该串在字符串数组中的位置(即下标值),若未找到则返回-1。ss所指字符串数组中共有N个内容不同的字符串,且串长小于M。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
#define N 5
#define M 8
int fun(char (*ss)[M], char *t)
int i;
/******************found*******************/
for(i=0; i<______; i++)
/******************found*******************/
if(strcmp(ss[i], t)==0)
return______;
return(-1);

main( )
char ch[N][M]("if", "while", "switch", "int", "for", t[M];
int n, i;
printf("/nThe original string/n/n");
for(i=0; i<N; i++)puts(ch[i]);
printf("/n");
printf("/nEnter a string for search:");
gets(t);
n=fun(ch, t);
/******************found*******************/
if(n==______)
printf("/nDon’t found!/n");
else
printf("/nThe position is %d./n", n);


[简答题]下列给定程序中,函数fun的功能是:求出s所指字符串中最后一次出现的t所指字符串的地址,并通过函数值返回,在主函数中输出从此地址开始的字符串;若未找到,则函数值为NULL。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动mam函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
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==’/0’)a=s;
s++;

return a;

void 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");

[多项选择]下列给定程序中,函数fun的功能是:将s所指字符串的正序和反序进行连接,形成的新串放在t所指的数组中。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动mam函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
/******************found*******************/
void fun(char s, char t)

int i, d;
d=strlen(s);
for(i=0; i<d; i++)
t[i]=s[i];
for(i=0; i<d; i++)
t[d+i]=s[d-1-i];
/******************found*******************/
t[2*d-1]=’/0’;

main( )

char s[100], t[100];
printf("nPlease enter string S:");
scanf("%s", s);
fun(s, t);
printf("/nThe result is: %s/n", t);

[填空题]在给定程序中,函数fun的功能是:在形参ss所指字符串数组中查找与形参t所指字符串相同的串,找到后返回该串在字符串数组中的位置(下标值),未找到则返回-1,ss所指字符串数组中共有N个内容不同的字符串,且串长小于N。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
#include<string.h>
#define N 5
#define M 8
int fun(char(*ss)[M],char *t)
int i:
/**********found**********/
for(i=0;i< (1) ;i++)
/**********found**********/
if(stremp(ss[i],t)==0)return (2)
return -1;

void main( )
char ch[N][M]="f","while","switch","int","for",t[M];
int n,i;
printf("/nThe original stringin/n");
for(i=0;i<N;i++)puts(ch[i]);
printf("/n");
printf("/nEnter a string for search: ");
gets(t);
n=fun(eh,t);
/**********found**********/
if(n== (3) )printf("/nDon’t found!/n");
else printf("/nThe position is%d./n",n);


[填空题]下列给定程序中,函数fun( )的功能是:首先把b所指字符串中的字符按逆序存放,然后将a所指字符串中的字符和b所指字符串中的字符,按排列的顺序交叉合并到c所指数组中,过长的剩余字符接在c所指数组的尾部。例如,当a所指字符串中的内容为abcdefg,b所指字符串中的内容为1234时,c所指数组中的内容应该为a4b3c2dlefg;而当a所指字符串中的内容为1234,b所指字符串中的内容为abcdefg时,c所指数组中的内容应改为1g2f3e4dcba。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序 #include <conio.h> #include <stdio.h> #include <string.h> void fun(char *a, char *b, char *c) { int i, j; char ch; i=0; j=strlen(b)-1; /*************found**************/ while (i>j} {ch=bill; b[i]=b[j]; b[j]=ch; i++; j--; } while (*a||*b) { if (*a){*c=*a; c++; a++;} if(*b){*c=*b; c++; b++;} } /*************found**************/ *c=0 ; } main ( ) { char s1[100],s2[100],t[200]; clrscr( ); printf("/nEnter s1 string: "); scanf ("%s", s1); printf("/nEnter s2 string: "); scanf ("%s", s2); fun(s1,s2,t); printf("/nThe result is :%s/n",t); }

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码