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

有以下程序#inelude(stdio.h>int f(int n);main(){int a=3,s;s=f(A);8=s+f(A);prinff(“%d\n”,

有以下程序

#inelude(stdio.h>

int f(int n);

main()

{int a=3,s;

s=f(A);8=s+f(A);prinff(“%d\n”,s);

}

int f(int n)

{static ifit a=1:

n+=a++:

return n;

}

程序运行后的输出结果是

A.7

B.8

C.9

D.10

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“有以下程序#inelude(stdio.h>int f(in…”相关的问题
第1题
有以下程序:#inelude <stdio.h>main(){int i,j,x=0;for(i=0;i<2;i++ ) {x++; for(j=0;j<=3;j ++

有以下程序:#inelude <stdio.h>main(){ int i,j,x=0; for(i=0;i<2;i++ ) { x++; for(j=0;j<=3;j ++) { fi(j%2) continue; x++; x++; } pfinff("x = % d\n",x);} 程序执行后的输出结果是()。

A.x=4

B.x=8

C.x=6

D.x=12

点击查看答案
第2题
有以下程序: #include < stdio. h > main () int a=3,b=4,c=5,d=2;if(a>b) if(b>c)printf("%d",

有以下程序: #include < stdio. h > main () int a=3,b=4,c=5,d=2; if(a>b) if(b>c)printf("%d",d++ +1); else printf("% d", + + d + 1 ); printf("% d \n" ,d); 程序运行后的输出结果是()。

A.2

B.3

C.43

D.44

点击查看答案
第3题
有以下程序#include<stdio. h>main(){charc1='1',c2='2';c1=getchar();c2=getchar();putchar(c1)

有以下程序#include<stdio. h>main(){ char c1='1',c2='2'; c1=getchar(); c2=getchar(); putchar(c1); putchar(c2);} 当运行时输入:a<回车> 后,以下叙述正确的是

A.变量c1被赋予字符a,c2被赋予回车符

B.程序将等待用户输入第2个字符

C.变量c1被赋予字符a,c2中仍是原有字符2

D.变量c1被赋予字符a,c2中将无确定值

点击查看答案
第4题
下列程序段的输出结果为()。#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

点击查看答案
第5题
有如下程序: #inelude<iostream> usingnamespacestd; classTest { public: Test(){n+=2
;} ~Test(){n-=3;} staticintgetNum(){returnn;} private: staticintn; }; intTest::n=1; intmain()

Test*P=newTest: deleteP; cout<<"n="<<Test::getNum()<<endl; return0; } 执行后的输出结果是()。

A.n=0

B.n=1

C.n=2

D.n=3

点击查看答案
第6题
以下程序打开新文件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);

}

点击查看答案
第7题
下面程序的运行结果是()。#inelude<stdio.h>void del(char*s){ int i,j;char*a;a=s:for(i=

下面程序的运行结果是()。

#inelude<stdio.h>

void del(char*s)

{ int i,j;

char*a;

a=s:

for(i=0,j=0;a[i]!='\0';i++)

{ if(a[i]>='0'&&a[i]<='9')

{s[j]=a[i];

j++;

}

s[j]='\0';

}

}

main

{ char*s="aa89gggh";

del(s):

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

}

A.1

B.2

C.3

D.4

点击查看答案
第8题
阅读以下说明和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

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

阅读以下说明和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();

}

点击查看答案
第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);

}

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