请补充main函数,该函数的功能是:先以只写方式打开文件file.dat,再把字符串S中的字符保存到这个磁
请补充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)
【 】;
else
【 】;
if(max<c)
【 】;
printf("max=%d\n",max);
}
请补充函数proc(),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如,str1=”I am a”,str2=”student”,结果输出:I am a student。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
请补充函数fun(),该函数的功能是:判断某一个年份是否为闰年。
例如,1900年不是闰年,2004是闰年。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<conio.h>
int fun(int n)
{
int flag=0;
if (n%4=0)
{
if (【 】)
flag=1;
}
if (【 】)
flag=1;
return【 】;
}
main()
{
int year;
clrscr();
printf("Input the year:");
scanf("%d", &year);
if (fun(year))
printf("%d is a leap year. \n", year);
else
printf("%d is not a leap year.\n",
year);
}
请补充函数proc,该函数的功能是计算下面公式SN的值:
SN=1+1/3十4/5+...+2N-1/SN-1
例如,当N=20时,SN=29.031674。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdlib.h>
include<conio.h>
include<stdio.h>
double proc(int n)
{
double s=1.0,sl=0.0;
int k;
for(【1】;k<=n;k++)
{
s1=S;
【2】
}
return【3】;
}
void main
{
int k=0:
double sum;
system("CLS");
printf("\nPlease input N=");
scanf("%d",&k);
sum=proc(k);
printf("\nS=%If",sum);
}
●试题四
请补充函数fun(),该函数的功能是将字符串tt中的大写字母都改为对应的小写字母,其他字符不变。例如,若输入"Are you come from Sichuan?",则输入"are you come from sichuan?"。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<string.h>
#include<conio.h>
char *fun(char tt[])
{
int i;
for(i=0;tt[i];i++)
{
if((tt[i]>=′A′)&&((1) ))
(2) ;
}
return ((3) ) ;
}
main()
{
char tt[81];
printf("\nPlease enter a string:");
gets(tt);
printf("\nThe result string is: \n%s",
fun(tt));
}
请补充main函数,该函数的功能是:计算每个学生成绩的平均分,并把结果保存在数组bb中。
例如,当scorer[N][M]={{83.5,82,86,65,67),{80,91.5,84, 99,95){90.5,95,86,95,97}}时,三个学生的平均分为76.7 89.9 92.7。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若千表达式或语句。
试题程序:
include<stdio.h>
define N 3
define M 5
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 bb[N];
clrscr();
for(i=0;i<N;i++)
【 】;
for(i=0;i<N;i++)
{
for (j=0; j<M; j++)
【 】;
bb [i]/=M;
}
for (i=0; i<N; i++)
print f (" knstudent %d\t average
=%5.1f",i+l,bb[i]);
}
请补充函数fun(),该函数的功能求能整除x且是偶数的数,把这些数保存在数组bb中,并按从大到小的顺序输出。
例如当x=20时,依次输出:20 10 4 2。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<conio.h>
include<stdio.h>
void fun(int k,int bb[ ])
{
int i;
int j=0;
for(【l】;i<=k;i++)
{
if(【 】)
bb[i++]=i;
}
printf("\n\n");
for(i=【 】;i>=0;i--)
printf(“%d”,bb[i]);
}
main()
{
int k=1;
int bb[100];
clrscr();
printf(“\nPlease input X=”);
scanf(“%d”,&k);
fun(k,bb);
}
●试题三
请补充函数fun(),该函数的功能是:只保留字符串中的大写字母,删除其他字符,结果仍保存在原来的字符串中,由全局变量m对删除后字符串的长度进行保存。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
int m;
void fun(char *s)
{
int i=0,j=0;
char *p=s;
while(*(p+i))
{
if(*(p+i)>=′A′&&*(p+i)<=′Z′)
{
(1) ;
}
(2) ;
}
s[j]=′\0′;
(3) ;
}
main()
{
char str[80];
clrscr();
printf("\nEnter a string:");
gets(str);
printf("\n\nThe string is:\%s\n",str);
fun(str);
printf("\n\nThe string of changing
is:\%s\n",str);
printf("\n\nThe length of changed string
is:\%d\n",m);
}
请补充函数fun(),该函数的功能是:把字符下标为非素数的字符从字符串sb中删除,把字符下标为素数的字符重新保存在字符串e口中。字符串sb从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdefghijkl”,输出“cdfhl”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
include <stdio.h>
define N 80
void fun(char s[],int n)
{
int i, j, k, flag;
【 】;
for(i=0; i<n; i++)
{
if (i>1)
s [k++] =s [i];
flag=I;
for(【 】; j<i&&flag; j++)
if (i%j==0)
{
flag=0;
【 】
}
}
s [k]='\0';
}
main()
{
int i=0, strlen=0;
char str[N];
clrscr ();
printf("\n Input a string:\n");
gets (str);
while (str [i] !='\0')
{
strlen++;
i++;
}
fun (str, strlen);
printf("\n*** display string ***\n");
puts (str);
}
请补充函数fun(),该函数的功能是:从‘a’到‘z’统计一个字符串中所有字母字符各自出现的次数,结果保存在数组aIf中。注意:不区分大小写,不能使用字符串库函数。
例如,输入: “A=abc+5*c”,结果为:a=2, b=l,c=2。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数run的横线上填入所编写的若干表达式或语句。
试题程序:
include<conio.h>
include<stdio.h>
define N 100
void fun(char *tt,int alf[])
{
int i
char *p=tt;
for(i=0;i<26;i++)
【 】;
while(*p)
{
if(*p>='A'&&*p<='z')
【 】;
if(*p>='a'&&*p<='Z')
alf[*p-'a']++;
【 】;
}
}
main()
{
char str[N];
char a='a';
int alf[26],k;
clrscr();
printf("\nPlease enter a char string:");
scanf("%S",str);
printf("\n**The original string**\n");
puts(str);
fun(str,alf);
printf("\n**The number of letter**\n");
for(k:0;k<26;k++)
{
if(k%5==0)
printf(“\n”);
printf(“%c=%d”,a+k,alf[k]);
}
printf(“\n”);
}