题目详情
当前位置:首页 > 计算机考试 > 计算机等级考试
题目详情:
发布时间:2023-10-21 13:13:05

[填空题]请补充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++; } ______; }

更多"请补充main( )函数,该函数的功能是:先以只写方式打开文件file"的相关试题:

[多项选择]填空题 请补充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 函数,该函数的功能是:先以只写方式打开文件“out99.dat”,再把字符串str中的字符保存到这个磁盘文件中。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include "stdio. h"
#include "conio.h"
#define N 80
main ( )

FILE *fp;
int i=0;
char ch;
char str[N]="I’m a student!";
clrscr( );
if ( (fp=fopen ( 【1】 ) ) ==NULL)

printf("cannot open out99. dat/n");
exit(0);

while (str[i])

ch=str[i];
【2】 ;
putchar(ch);
i++;

【3】 ;

[填空题]请补充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 函数,该函数的功能是:求n! 例如7!=5040。 注意:部分源程序给出如下。 请勿改动主函数main 和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。 试题程序: # include<stdio. h> #include<conio. h> main( ) { int i,n; long f=1; clrscr ( ); printf("Input n: "); scanf ("%d", 【1】 ); for( 【2】 ;i<=n; i++) 【3】 ; printf ("%d!=%1d/n", n, f); }
[填空题]请补充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函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。 例如:当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函数。该函数的功能是:求1~100(不包括100)以内所有素数的平均值。 程序运行后的结果为42.40。 注意:部分源程序给出如下. 请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> main( ) { int i, j, n=0,flag; float aver=0; clrscr( ); for(j=2;j<100;i++) { flag=1; for(i=2;i<j;i++) if( 【1】 ) { flag=0; break; } if( 【2】 ) { n++; aver+=j; } } printf("/n/n average=%4.2f", 【3】 ); }
[填空题]请补充main函数。该函数的功能是:求1~100(不包括100)以内所有素数的平均值。
程序运行后的结果为42.40。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
main( )

int i, j, n=0,flag;
float aver=0;
clrscr( );
for(j=2;j<100;i++)

flag=1;
for(i=2;i<j;i++)
if( 【1】 )

flag=0;
break;

if( 【2】 )

n++;
aver+=j;


printf("/n/n average=%4.2f", 【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函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当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函数,该函数的功能是:打印出1~1000中满足:个位数字的立方等于其本身所有数。 本题的结果为;1 64 125 216 729 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数main的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio .h> main ( ) { int i,g; clrscr ( ); for (i=1; i<1000; i++) { g= 【1】 ; if( 【2】 ) printf ("%4d", i); } }
[填空题]请补充main 函数,该函数的功能是:把文本文件B中的内容追加到文本文件A的内容之后。 例如,文佃的内容为“I’m ten.”,文件A的内容为“I’ m a student!”,追加之后文件A的内容为“I’m a student !I’m ten.” 注意:部分源程序给出如下。 请勿改动主函数main 和其他函数中的任何内容,仅在函数main 的横线上填入所编写的若干表达式或语句。 试题程序: # include<stdio, h> #include<conio. h> #define N 80 main( ) { FILE *fp, * fp1, *fp2; int i; char c[N] ,t, ch; clrscr ( ); if ((fp=fopen ("A. dat ", "r") ) == NULL) { printf ("file A cannot be opened/n"); exit (0); } printf("/n A contents are : /n/n"); for (i=0; (ch=fgetc (fp)) !=EOF; i++) { C [i]=ch; putchar (c [i]); fclose (fp); if((fp=fopen ("B. dat", "r") )==NULL) { printf ("file B cannot be opened/n"); exit (0); } printf("/n/n/nB contents are : /n/n"); for (i=0; (ch=fgetc (fp)) !=EOF; i++) { c [i] =ch; putchar (c [i]); } fclose (fp); if ( (fp1=fopen ("A.dat" ,"a")) 【1】 (fp2 =fopen ("B. dat", "r") ) ) { while ( (ch=fgetc (f
[填空题]请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在N[10]中。
例如:当str1=“ab123456789cde090”时,结果为:
0: 2 1: 1 2: 1 3: 1 4: 1 5: 1 6: 1 7: 1 8: 1 9:2 other charactor:5
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#include <conio.h>
main( )

int i,b[11];
char *str="abl23456789cde090";
char *p=str;
clrscr( );
printf("***the origial data ***/n");
puts(str);
for(i=0;i<11;i++)
b[i]=0;
while(*p)

switch( 【1】 )

case ’0’:b[0]++;break;
case ’1’:b[1]++;break;
case ’2’:b[2]++;break;
case ’3’:b[3]++;break;
case ’4’:b[4]++;break;
case ’5’:b[5]++;break;
case ’6’:b[6]++;break;
case ’7’:b[7]++;break;
case ’8’:b[8]++;break;
case ’9’:b[9]++;break;

[填空题]请补充main函数,该函数的功能是:打印出1~1000中满足:个位数字的立方等于其本身所有数。
本题的结果为;1 64 125 216 729
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数main的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio .h>
main ( )

int i,g;
clrscr ( );
for (i=1; i<1000; i++)

g= 【1】 ;
if( 【2】 )
printf ("%4d", i);


我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
  • 支付完成
  • 取消支付
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码