更多"请补充main函数,该函数的功能是:输出一个3×3的矩阵,要求必须使用"的相关试题:
[填空题]请补充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函数,该函数的功能是:输出一个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( ),该函数的功能是:把从键盘输入的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~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函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“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);
[简答题]填空题
请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define N 80
void main( )
{
int j;
char str[N]=" 123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("***original string ***/n");
puts(str);
【1】;
while(*(pf+j))
{
if(*(pf+j)>=’’a’’&&*(pf+j)<=’’z’’)
{
*(pf+j)=【2】;
j++;
}
else
【3】;
}
printf("******new string******/n");
puts(str);
system("pause");
}
[填空题]请补充main函数,该函数的功能是:把一个整数插入到一个已经按从小到大排序的数组中。插入后,数组仍然有序。
例如,在数组bb[N]=12,23,31,44,51,63,71,79,85,95中插入93,结果为:
bb[N]11,21,31,41,51,61,7l,79,8l,93,95
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<std/o. h>
#define N 10
main( )
int i,j;
int n;
int bb IN+l] = t2,23, 31, 44, 51, 63, 71,
79,85,95;
clrscr ( );
printf("/nInput n /n");
scanf ("%d", &n);
printf ("/nn=%d ",n);
printf("/n*** original list ***In");
for (i=0; i<N; i++)
printf ("%4d ",bb [ii );
for (i=0; i<N; i++)
if (n<=bb [i ] )
for(j=N; 【1】 ;j--)
【2】;
bb [j] =n;
【3】;
if (i=N)
bb[i]=n;
printf("/n***** new list ******In");
for (i=0;i<N+l; i++)
printf ("%4d ",bb [i]);
[填空题]请补充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);
}
[填空题]请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]“123 abcdef ABCDEF!”,结果输出:
“123ABCDEFABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define N 80
void main( )
int j;
char str[N]="123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("*** original string ***/n");
puts(str);
【1】 ;
while(*(pf+j)).
if(*(pf+j)>=’a’&&* (pf+j)<=’z’)
*(pf+j)= 【2】 ;
j++;
else
【3】 ;
printf("****** new string ******/n");
puts(str);
system("pause");
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
main( )
char str1[LEN],str2 [LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr( );
printf("Enter the string:/n");
scanf( 【1】 );
printf("***the origial string***/n");
while(*(p1+j))
printf(" 【2】 ",*(p1+j));
j++;
for(i=0;i<j;i+=2)
*p2++=*(str1+i);
*p2=’/0’;
printf("/nThe new string is:%s/n", 【3】 );
[多项选择]填空题
请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define LEN 80
main( )
{
char str1[LEN],str2[LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr( );
printf("Enter the string:/n");
scanf(【1】);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("【2】",*(p1+j));
j++;
}
for(i=0;i
[填空题]请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。
例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
main( )
char str1[LEN],str2[LEN];
int n,i;
clrscr( );
printf("Enter the string:/n");
gets(str1);
printf "Enter the position of the string deleted:");
scanf( 【1】 );
for(i=0;i<n;i++)
【2】
str2[i]=‘/0’;
printf("The new string is:%s/n", 【3】 );