首页 > 计算机等级考试
题目内容 (请给出正确答案)
[主观题]

有以下程序#include<stdio.h>void fun(char**p){++p;printf("%s",*p);}main{cha

有以下程序

#include<stdio.h>

void fun(char**p)

{++p;printf("%s",*p);}

main

{char*a[]={"Morning","Afternoon","Evening"," Night");

fun(a);

}

程序的运行结果是()。

A.Afternoon

B.fternoon

C.Morning

D.orning

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“有以下程序#include<stdio.h>void fun…”相关的问题
第1题
下列程序段的输出结果为()。#include<stdio. h>main(){ static char a[]="language";char*p; p=a;

下列程序段的输出结果为()。#include<stdio. h>main(){ static char a[]="language"; char*p; p=a; for(p=a;p<a+8;p+=2) putchar(*p);}

A.language

B.lnug

C.有语法错误

D.lang

点击查看答案
第2题
以下程序打开新文件f.txt,并调用字符输出函数将a数组中的字符写入其中,请填空。include<stdio.

以下程序打开新文件f.txt,并调用字符输出函数将a数组中的字符写入其中,请填空。

include<stdio.h>

main()

{________*fp;

char a[5]=(’1’,’2’,’3’,’4’,’5’),i;

fp=fopen(”f.txt”,”w”);

for(i=0;i<5;i++)fputc(a[i],fp);

fclose(fp);

}

点击查看答案
第3题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include < stdio. h >include

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。

【C++程序】

include < stdio. h >

include < string. h >

define Max 1000

class Bank

{

int index;

char date [Max] [10]; // 记录交易日

iht amount[Max]; // 记录每次交易金额,以符号区分存钱和取钱

int rest[ Max]; // 记录每次交易后余额

static iht sum; // 账户累计余额

public:

Bank() {index =0;}

void deposit(char d[ ] , int m) //存入交易

{

strcpy (date [ index ], d);

amount[ index] = m;

(1);

rest[ index] = sum;

index++;

}

void withdraw (char d[ ], int m) //取出交易

{

strcpy(date[ index] ,d);

(2);

(3);

rest[ index] = sum;

index++;

}

void display();

};

int Bank:: sum = 0;

void Bank:: display () //输出流水

{

int i;

printf("日期 存入 取出 余额\n");

for (4)

{

printf(" %8s" ,date[i] );

if (5)

printf(" %6d" , -amount[i] );

else

printf("%6d ",amount[i] );

printf("% 6d\n" ,rest[i] );

} }

void main()

{

Bank object;

object. deposit ("2006.2.5", 1 00 );

object. deposit("2006.3.2" , 200);

object. withdraw("2006.4.1", 50);

object. withdraw("2006.4.5", 80);

object. display ();

}

本程序的执行结果如下:

日期 存入 取出 余额 2006.2.5 100 100

2006.3.2 200 300

2006.4.1 50 250

2006.4.5 80 170

点击查看答案
第4题
阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 本程序用于评选优秀教

阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。

【说明】

本程序用于评选优秀教师和学生。当输入一系列教师或学生的记录后,将优秀学生及教师的姓名列出来。其类结构如下图所示:

【程序】

include <iostream.h>

include <stdio. h>

class base

{

protected:

char name[8];

public:

void getname(){cout<<"name:"; cin>>name;}

void printname(){cout<<"name:"<<name<<endl;}

(1)

};

class student: (2)

{

int num;

public:

void getnum()

{cout<<"score:"; cin>>num;}

bool isgood()

{return (3) }

};

class teacher: (2)

{

int num;

public:

void getnum()

{cout<<"paper:"; cin>>num;}

bool isgood()

{return (num>3)?true:false;}

void main()

{

base *p[50];

student *pstud;

teacher *ptech;

char ch;

int count=0;

do{

cout<<"input teacher(t) or student(s):";

cin>>ch;

if(ch=='s')

{

pstud=new student;

pstud->getname();

pstud->getnum();

p[count++]=pstud;

}

else if(ch=='t')

{

(4)

ptech->getname();

ptech->getnum();

p[count++]=ptech;

}

else

cout<<"input is wrong"<<endl;

cout<<"continue to iput(y/n)?";

cin>>ch;

}while(ch=='y');

for(int i=0;i<count;i++)

if((5))

p[i]->printname();

}

点击查看答案
第5题
下列给定程序中,函数fun()的功能是;求S的值。设 S=(22/1*30))*(42/(3*5))*(62/(5*7))*…*(2k)2/((2

下列给定程序中,函数fun()的功能是;求S的值。设 S=(22/1*30))*(42/(3*5))*(62/(5*7))*…*(2k)2/((2k-1)*(2k+1))

例如,当k为10时,函数的值应为1.533852。

请改正程序中的错误,使它能得出正确的结果。

注童;不要改动main 函数,不得增行或删行,也不得更改程序的结构。

试题程序:

include <conio. h>

include <stdio. h>

include <math.h >

/**************found***************/

fun (int k)

{ iht n; float s, w, p, q;

n=1;

s=1.0;

while (n<=k)

{ w=2. 0*n;

p=w-1.0;

q=w+1.0;

s=s*w*w/p/q;

n++;

}

/***************found**************/

return s

}

main()

{ clrscr ();

printf ("%f\n ", fun (10));

}

点击查看答案
第6题
阅读以下说明,回答问题1~4,将解答填入对应的解答栏内。[说明] 输入1个长整型,求各位数字的平方和。

阅读以下说明,回答问题1~4,将解答填入对应的解答栏内。

[说明] 输入1个长整型,求各位数字的平方和。

例如:输入-123,输出14。

include <stdio. h>

void main()

{ int digit;

long in , s;

seanf(" % Id", &in );

(1);

(2);

while(in >0) {

(3);

s = s + digit* digit;

(4);

}

pfinff("sum = % 1dn", s );

}

点击查看答案
第7题
下列给定程序中,函数fun()的功能是:根据整型参数m,计算如下公式的值。 y=1/(100×100)+1/(200×200)

下列给定程序中,函数fun()的功能是:根据整型参数m,计算如下公式的值。

y=1/(100×100)+1/(200×200)+1/(300×300)+…+1/(m×m)

例如,若m=2000,则应输出0.000160。

请改正程序中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。

试题程序:

include <conio.h>

include <stdio. h>

/*************found**************/

fun (int m)

{ double y=0, d;

int i;

/*************found**************/

for (i=100, i<=m, i+=100)

{d= (double) i* (double) i;

y+=l. 0/d;

}

return (y);

}

main ()

{ int n=2000;

clrscr();

printf("\nThe result is %lf\n",fun(n));

点击查看答案
第8题
已知C源程序如下:/ * longIntAdd * / include <stdio. h> include <string. h> defi

已知C源程序如下:

/ * longIntAdd * /

include <stdio. h>

include <string. h>

define LENGTH 81

void addLInt(char sl[],char s2[]); void reverse(char s[]) ; int main()

{

char intstrl[LENGTH],intstr2[LENGTH];

printf("请输入超长整数的被加数和加数:\n")

scanf("%s%s" ,intstrl ,intstr2) ; addLInt(intstrl ,intstr2) j printf("超长整数和为: %s" .intstrl); return 0;

}

void addLInt(char sl[] ,char s2[]) {

int i=0,tmp,c=0;

char s[LENGTH];

if(strlen(s1)<strlen(s2)){ strcpy(s,sl); strcpy(sl,s2); strcpy(s2,s);

}

reverse(sl);reverse(s2);

while(s2[i]! ='\0'){

tmp=sl[i]-'0'+s2[i]-'0'+ c;

sl[i] = tmp%10+,0';

c=tmp/10;

i++; } while(sl[i]! ='\0,&&c){

tmp=sl[i] —'0' + c;

sl[i] = tmp%10+'0';

c=tmp/10;

i++; } If(c){

sl[i++] = c+'0';

sl[i] = '\0'; } reverse(sl);

}

void reverse(cliar s[])

{

inti,j,c;

for(i=0,j = strlen(s) -l;i<j;i++,j--){

c=s[i]; s[i] = s[j]; s[j] = c; } }

(1)画出程序中函数addLInt的控制流程图(10分);

(2)设计一组测试用例,使该程序addLInt函数的语句覆盖率和分支覆盖率均能达到100%。如果认为该函数的语句覆盖率或分支覆盖率无法达到100%,需说明为什么(10分)。

点击查看答案
第9题
请编写函数fun(),该函数的功能是:计算并输出 S=1+(1+20.5)+(1+20.5+30.5)+…+(1+20.5+30.5+…+n0.5

请编写函数fun(),该函数的功能是:计算并输出

S=1+(1+20.5)+(1+20.5+30.5)+…+(1+20.5+30.5+…+n0.5)

例如,若主函数从键盘给n输入20后,则输出为

s=534.188884。

注意;部分源程序给出如下。

请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。

试题程序:

include <math. h>

include <stdio. h>

double fun(int n)

{

}

main()

{

int n;

double s;

printf("\n\nInput n: ");

scanf ("%d", &n);

s=fun (n)

printf ("\n\ns=%f\n\n", s);

}

点击查看答案
第10题
下列程序的功能是:计算出自然数SIX和NINE,它们满足的条件是SIX+SIX+SIX=NINE+NINE的个数 cnt,以
及满足此条件的所有SIX与NINE的和sum。请编写函数countValue()实现程序要求,最后调用函数 writeDAT()把结果cnt和sam输出到文件OUT51.DAT中。其中的S,L X,N,I,N,E各代表一个十进制数。

注意:部分源程序已给出。

请勿改动主函数main()和写函数writeDAT()的内容。

试题程序:

include<stdio. h>

int cnt, sum;

void countValue()

{

}

void main ()

{

cnt=sum=O;

countValue ();

printf ("满足条件的个数=%d\n", cnt);

printf ("满足条件所有的SIX与NINE的和=%d\n", sum);

writeDAT ();

}

writeDAT ()

{

FILE *fp;

fp=fopen("OUT51.DAT", "w");

fprintf (fp, "%d\n%d\n", cnt, sum);

fclose (fp);

}

点击查看答案
第11题
请编写一个函数void fun(char*ss),其功能是:将字符串 ss中所有下标为偶数位置上的字母转化为大写

请编写一个函数void fun(char*ss),其功能是:将字符串 ss中所有下标为偶数位置上的字母转化为大写(若该位置上不是字母,则不转换)。

例如,若输入abc4Efg,则应输出AbC4EfG。

注意:部分源程序给出如下。

请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。

试题程序:

include<conio. h>

include<stdio. h>

void fun (char *ss)

{

}

main ()

{

char tt[51];

clrscr ();

printf("Please enter an character string

within 50 characters:\n");

gets (tt);

printf ("\n\nAfter changing, the string\n

%s", tt);

fun (tt);

printf("\nbecomes\n \%s",tt);

}

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改