更多"请补充主函数main( ),该函数的功能是:把从键盘输入的3个整数按从"的相关试题:
[填空题]请补充函数fun( ),该函数的功能是:把从键盘输入的3个整数按从小到大输出。
例如:输入“33 78 25”,结果输出“25 33 78”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的横线上填入所编写的若干表达式或语句。
试题程序:
# include<stdio. h>
# include<conio. h>
main( )
int x,y, z,t;
clrscr ( );
printf ("Input x, y, z/n");
scanf ("%d%d%d", &x, &y, &z);
if( 【1】 )
t=x;
x=y;
y=t;
/*变换x, y的值*/
if( 【2】 )
t=z;
z=x;
x=t;
/*交换x, z 的值*/
if( 【3】 )
t=y;
y=z;
z=t;
/*变换 z, y 的值*/
printf("******the result*******/n");
printf("from small to big: %d %d %d/n",
x, y, z);
[填空题]请补充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);
[简答题]给定一个函数,其函数功能为:使10个整数按由小到大的顺序排列。在主函数中输入10个数,并输出结果。使用VC6打开考生文件夹下的工程RevProj5。此工程包含一个源程序文件RevMain5.cpp,该程序实现上述功能。但此程序运行有问题。请找出错误的地方,改正后将此程序调试正确。
注意:不得删行或增行,也不得更改程序结构。
文件RevMain5.cpp中的程序清单如下:
//RevMain5.cpp
#include<iostream>
#include<iomanip>
using namespace std;
int main( )
{
void sort(int array[],int n);
int data[10],*p,i;
cout<<"Input 10 numbers/n";
for (i=0; i<10; i++)
cin>>data [i];
cout<<"the origined array is:";
for (p=data;p<data+10;p++)
{
if((p-&data[0]) %5==0)
cout<<" /n";
cout<<setw (5) <<*p;
}
sort (data, 10);
cout<<"/n the present array is:";
for(p=data;p〈data+10;p++)
{
if((p-&data[0])%5==0) cout<<"/n";
cout<<setw (5)<<*p;
}
}
void sort(int array[],int n)
{
/* * * * * * * * *found * * * * * * * * * */
for(p1=array;p1<array+(n-1) ;p1++)
{
for (p2=p1+1 ;p2<array+n;p2++)
{
if (*p1>*p2)
{
/* * * * * * * * *found * * * * * * * * * */
[填空题]请补充main函数,该函数的功能是:从键盘输入一组整数,使用条件表达式找出最大的整数。当输入的整数为0时结束。
例如,输入1,2,3,5,4,0时,最大的数为5。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写出的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 100
main( )
int num[N];
int i=-1;
int max=0;
clrscr( );
printf("/nInput integer number:/n");
do
i++;
printf("num[%d]=",i);
scanf("%d", 【1】 );
max= 【2】 num[i]:max;
while ( 【3】 );
printf("max=%dkn",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函数,该函数的功能是:从键盘输入一个字符串并保存在字符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中,把字符串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",______);
}
[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如:str1=“How do”,str2=“you do”,结果输出:How do you do
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 40
void fun(char *str1,char *str2)
int i=0;
char *p1=str1;
char *p2=str2;
while( 【1】 )
i++;
for( ; 【2】 ;i++)
*(p1+i)= 【3】 ;
*(p1+i)=’/0’;
main( )
char str1[N],str2[N);
clrscr( );
printf("*****Input the string str1 & str2*****/n");
printf("/nstr1:");
gets(str1);
printf("/nstr2:");
gets(str2);
printf("**The string str1 & str2**/n");
puts(str1);
puts(str2);
fun(str1,str2);
printf("*****The new string *****/n");
puts(str1);
[填空题]请补充main函数,该函数的功能是:从键盘输入学生的成绩(用回车键作为分隔符),并统计各分数段学生的人数。具体要求为:A类为90~100分,B类为80~89分,C类为70~79分,D类为60~69分,59分以下的为E类。当成绩为0时结束成绩的输入,并且最后输入的0不进行统计。
例如,输入89,99,45,64,56,78,88,74,66,55,0。结果为
A:1 B:2 C://2 D://2 E://3
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 100
main( )
float score[N];
int bb[5];
int grade, i=-1,n=0;
char ch=’A’;
clrscr( );
printf("Input a score(0~100);/n");
do
i++;
n++;
printf("score[%d]=",i);
scanf ( 【1】 );
while (score[i]!=0);
for(i=0;i<5;i++)
【2】 ;
for(i=0;i<n-1;i++)
grade= 【3】 ;
switch(grade)
case 10:
case 9:bb[0]++;break;
case 8:bb[1]++;break;
case 7:bb[2]++;break;
case 6:bb[3]++; break;
default:bb[4]++;
[填空题]请补充main函数,该函数的功能是:从键盘输入两上字符串并分别保存在字符数组str1和str2中,用字符串str2替换字符串str1前面的所有字符,注意,str2的K度不大于str1,否则需要重新输入。
例如,如果输入strl;=“abced”,str2=“fk”,则输出“fkced”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<string. h>
main ( )
char strl [ 81], str2 [ 81 ];
char *pl=strl, *p2=str2;
clrscr ( );
do
printf(" Input strl tn");
gets (strl);
printf(" Input str2 In");
gets (str2);
while(【1】);
while(【2】)
*p1++=*p2++;
printf(" Display strl /n");
puts (【3】)
[填空题]请补充main函数,该函数的功能是:从键盘输入一个长整数,如果这个数是负数,则取它的绝对值,并显示出来。
例如:输入-12345678,结果为12345678。
注意:部分源程序已给出。
请勿改动函数中的其他任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
void main( )
long int n;
printf("Enter the data:/n");
seanf( (1) );
printf("*****the origial data*****/n");
if(n<0)
(2)
printf("/n/n");
printf( (3) );