更多"请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素"的相关试题:
[填空题]请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素赋值0,周边元素赋值1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio .h>
#define N 10
main( )
int bb[N] IN];
iht i,j,n;
clrscr 0;
printf (" /nInput n: /n");
scanf ("%d", &n);
for (i=0; i<n; i++ )
for (j=0; j<n; j++)
if(【1】)
bb[i] [j]=l;
else
【2】;
printf(" /n*** the result *** /n");
for (i=0; i<n; i++)
printf (" /n/n");
for (j=0; j<n; j++)
printf ("%4d",bb [i] [j ] );
[填空题]请补充main函数,该函数的功能是:输出一个N×N矩阵,要求非对角线上的元素赋值为0,对角线元素赋值为1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#define N 10
main ( )
int bb[N] [N];
int i, j,n;
clrscr ( );
printf (" /nInput n:/n");
scanf ("%d", &n);
for (i=0; i<n; i++)
for (j=0; j<n; j++)
【1】 ;
if (i==j)
bb[i] [j]= 【2】 ;
if ( 【3】 )
bb[i] [j]=1;
printf(" /n***** the result ***** /n");
for (i=0; i<n; i++)
printf (" /n/n");
for (j=0; j<n; j++)
printf ("%4d",bb [i] [j] );
[填空题]请补充main( )函数,该函数的功能是:输出一个4×4的矩阵,要求必须使用行指针表示输出变量。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在main( )函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
static int arr[4][4]=(9,8,7,6),
6,5,4,3,
3,2,1,0,
2,4,6,8;
int(*p)[4],j,i;
p= (1) ;
system("CLS");
for(i=0;i<4;i++)
printf("/n/n");
for(j=0;j<4;j++)
printf("%4d", (2) );
[填空题]请补充main函数,该函数的功能是:输出一个3×3的矩阵,要求必须使用行指针表示输出变量。
注意;部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<s tdio. h>
main( )
{
static int array[3] [3]={{9,8,7}, {6,5,
4}, (3,2,1}};
iht (*p) [3],j,i;
p=【1】
clrscr ( );
for (i=0; i<3; i++)
{
printf (" /n/n" );
for (j=0; j<3; j++)
printf("%4d", 【2】 );
}
}
[填空题]请补充main( )函数,该函数的功能是:把一个二维字符数组每行字符串中最大的字符复制到字符数组s中。
例如,如果arr[3]="hoih", "yufui", "xgf",则str="oyx"。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
int i=0;
char *arr[3]="hoih", "yufui", "xgf";
char **p;
char str[8];
system("CLS");
(1) ;
for(i=0; i<3; i++)
str[i]= *p[i];
while(* p[i])
if (str[i]<*p[i])
str[i]=*p[i];
(2) ;
(3) ;
printf("new string/n");
puts(str);
[填空题]请补充main函数,该函数的功能是:从键盘输入3个整数,然后找出最大的数并输出。
例如,输入:12,45,43,最大值为45。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
main( )
int a, b, c, max;
clrscr( );
printf("/nlnput three numbers:/n");
scanf("%d,%d,%d",&a,&b,&c);
printf("The three numbers are:%d,
%d,%d/n",a,b,c);
if(a>b)
【1】 ;
else
【2】 ;
if(max<c)
【3】 ;
printf("max=%d/n",max);
[填空题]请补充main函数,该函数的功能是:从键盘输入3个整数,然后找出最大的数并输出。
例如,输入:12,45,43,最大值为45。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
main( )
{
int a, b, c, max;
clrscr( );
printf("/nlnput three numbers:/n");
scanf("%d,%d,%d",&a,&b,&c);
printf("The three numbers are:%d,
%d,%d/n",a,b,c);
if(a>b)
【1】 ;
else
【2】 ;
if(max<c)
【3】 ;
printf("max=%d/n",max);
}
[填空题]请补充main( )函数,该函数的功能是:计算每个学生成绩的平均分,并把结果保存在数组aver中。
例如,当score[N][M]=(83.5,82,86,65,67,80,91.5,84,99,95,90.5,95,86,95,97时,3个学生的平均分为76.7 89.9 92.7。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在main( )函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define N 3
#define M 5
void main( )
int i,j;
static float score[N][M]=(83.5,82,86,65,67),80,91.5,84,99,95,90.5,95,86,95,97;
float aver[N];
system("CLS");
for(i=0;i<N;i++)
(1) ;
for(i=0;i<N;i++)
for(j=0;j<M;j++)
(2) ;
aver[i]/=M;
for(i=0;i<N;i++)
printf("/nstudent%dktaverage=%5.1f",i+1,aver[i]);
[填空题]请补充fun( )函数,该函数的功能是求m的阶乘。不要改动主函数main( )与他函数中的任何内容,仅在fun( )函数的横线上填写所需的若干表达式或语句。
注意:部分源程序如下。
#include<stdio.h>
long fun(int m)
if (1)
return(m*fun (2) );
return (3) ;
main( )
printf("8!=%ld/n",fun(8));
[填空题]请补充main函数,该函数的功能是:输出方程组“A+B=56,A+2B=72”的一组正整数解。本题的结果是: A=40,B=16。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
main( )
{
int i, j;
clrscr ( );
for(i=0;i<100; i++)
for (j=0; j<100; j++)
if( 【1】 )
printf ("A=%2d,B=%2d", 【2】 );
}
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“abcdef”,指定字符为‘e’,则输出“abcd”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main ( )
{
int i=0;
char str [N];
char ch;
clrscr ( );
printf{"/n Input a string:/n");
gets (str);
printf("kn Input a charator;/n");
scanf ("%c", &ch);
while (str [i] !=’/0’)
{
if (str [i]==ch)
【1】
【2】 ;
}
str[i]= 【3】 ;
printf{"/n*** display string ***/n");
puts (str);
}