更多"请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素"的相关试题:
[填空题]请补充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( )函数,该函数的功能是:把1~100的所有素数保存在数组arr中,然后输出这些素数并计算它们的和。
注意:部分源程序给出如下。
请勿改动main( )函数和其他函数中的任何内容,仅在main( )函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
{
int i,j,k,flag,sum;
int arr[50];
sum=0;
k=0;
system("CLS");
for(i=2;i<100;i++)
{
______;
for(j=2;j<i&&flag;j++)
if(i%j==0)
{
______;
}
if(flag)
{
sum+=i;
______;
}
}
printf("/n***prime nHmber***/n");
for(i=0;i<k;i++)
{
if(i%10==0)
printf("/n");
printf("%4d",arr[i]);
}
printf("/nsum=%d",sum);
}
[填空题]请补充fun( )函数,fun函数的功能是求m的阶乘。
请勿改动main( )函数与其他函数中的任何内容,仅在fun( )函数的横线上填写所需的若干表达式语句。
注意:部分源程序给出如下。
试题程序:
#include<stdio.h>
long fun(int m)
{
if(______)
return(m*fun(______));
return ______;
}
void main( )
{
printf("8!=%ld/n",fun(8));
}
[填空题]请补充main( )函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1="computer",则str2="cmue"。
注意:部分源程序给出如下。
请勿改动函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define LEN 80
void main( )
{
char str1[LEN],str2[LEN];
char*p1=str1,*p2=str2;
int i=0,j=0;
system("CLS");
printf("Enter the string:/n");
scanf(______);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("______",*(p1+j));
j++;
}
for(i=0;i<j;i+=2)
*p2++=*(str1+i);
*p2="/0";
printf("/nThe new string is:%s/n",______);
}
[填空题]请补充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个整数按从小到大输出。
例如,输入“50 60 40”,结果输出“40 50 60”。
注意:部分源程序给出如下。
请勿改动main( )函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main( )
{
int x,y,z,s;
system("CLS");
printf("Input x,y,z/n");
scanf("%d%d%d",&x,&y,&z);
if(______)
{
s=x;
x=y;
y=s;
}
//交换x,y的值
if(______)
{
s=z;
z=x;
x=s;
}
//交换x,z的值
if(______)
{
s=y;
y=z;
z=s;
}
//交换z,y的值
printf("****the result****/n");
printf("from small to big:%d%d%d/n",x,y,z);
}
[填空题]请补充main( )函数,该函数的功能是:打印出1~10000中满足个位数字的立方等于其本身的所有数。
本题的结果为:1 64 125 216 729
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
int i, k;
system("CLS");
for(i=1; i<10000; i++)
k= (1) ;
if( (2) )
printf("%4d", i);
[填空题]请补充main函数,该函数的功能是:把1~100间的所有素数保存在数组aa中,然后输出这些素数并计算它们的和。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
main( )
int n, i, j, k, flag, sum;
int aa [50];
sum=O;
k=O;
clrscr ( );
for (i=2; i<100; i++)
【1】;
for (j=2; j<i&&flag; j++)
if (i%j==O)
【2】;
if (flag)
sum+=i;
【3】;
printf("/n*** prime number ***/n");
for (i=0; i<k; i++)
if (i%10==0)
printf ("/n");
printf ("%4d", aa [i]);
printf ("/nsum=%d", sum);
[填空题]请补充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( )函数,该函数的功能是:先以只写方式打开文件file.dat,再把字符串s中的字符保存到这个磁盘文件中。请勿改动main( )函数与其他函数中的任何内容,仅在的横线上填写所需的若干表达式或语句。
注意:部分源程序给出如下。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define N 100
void main( )
{
FILE*f;
int i=0;
char ch;
chair s[N]="Welcome!";
if((f=fopen|("______", "w"))==NULL)
{
printf("cartnot open file.dat/n");
exit(0);
}
while(s[i])
{
ch=s[i];
______;
putchar(ch);
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( )函数,该函数的功能是求出1!+2!+3!+4!…+N!的和。
例如,1!+2!+3!+4!+…+9!=409113。
注意:部分源程序给出如下。
仅在横线上填写所需要的若干表达式或语句,请勿改动函数中的其他任何内容。
试题程序:
#include<stdio.h>
void main( )
{
int i, n;
long sum=0, temp=1;
printf("/nInput n: /n");
scanf("%d", ______);
for(i=1; i<=n; i++)
{
temp=______;
sum=______;
}
printf("1!+…+%d!=%1d/n", n, sum);
}