重要提示:请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
首页 > 计算机类考试> 计算机二级> C++
网友您好,请在下方输入框内输入要搜索的题目:
搜题
拍照、语音搜题,请扫码下载APP
扫一扫 下载APP
题目内容 (请给出正确答案)
[主观题]

阅读以下程序: include<iostream.h> void main() { static int a[][3]={9,7,5,3,1,2,4,6,8}; int

阅读以下程序:

include<iostream.h>

void main()

{

static int a[][3]={9,7,5,3,1,2,4,6,8};

int i,j,s1=0,s2=0;

for(i=0;i<3;i++)

for(j=0;j<3;j++)

{

if(i==j)s1=sl+a[i][j];

if(i+j==2)s2=s2+a[i][j];

}

cout<<s1<<","<<s2<<endl;

}

则该程序的输出结果为【 】。

答案
查看答案
更多“阅读以下程序: include<iostream.h> void main() { static int a[][3]={9,7,5,3,1,2,4,6,8}; int”相关的问题

第1题

阅读以下程序#include<iostream.h>void main(){charline[10];in>>line;cout<<line<<endl;}如运行

阅读以下程序 #include<iostream.h> void main() { charline[10]; in>>line; cout<<line<<endl; } 如运行时输入This is an example.<CR>,则程序的输出结果是()。

A.This

B.This is

C.This is a

D.This is an example.

点击查看答案

第2题

阅读以下程序: #include main()

A.定义语句出错,case是关键字,不能用做用户自定义标识符

B.定义语句出错,printF不能用做用户自定义标识符

C.定义语句无错,scanf不能作为输入函数使用

D.定义语句无错,printf不能输出case的值

点击查看答案

第3题

请阅读以下程序:#include<stdio.h>main(){ int x=1,y=0,a=0,b=0;switch(x){ case 1:switch(y){ case 0:a++;break; }case 2:a++,b++;break; }printf(" a=%d,b=%d\n",a,b);上面程序的输出结果是

A.a=2,b=1

B.a=1,b=1

C.a=1,b=0

D.a=2,b=2

点击查看答案

第4题

阅读以下程序及对程序功能的描述,其中正确的描述是#include <stdio.h>main(){ FILE *in,*o

阅读以下程序及对程序功能的描述,其中正确的描述是#include <stdio.h>main(){ FILE *in,*out; char ch,infile[10],outfile[10]; printf("Enter the infile name:\n"); scanf("%s",infile); printf("Enter the outfile name:\n"); scanf("%s",outfile); if((in=fopen(infile,"r"))==NULL) { printf("cannot open infile\n"); exit(0); } if((out=fopen(outfile,"w"))==NULL) { printf("cannot open outfile\n"); exit(0); } while(! feof(in))fputc(fgetc(in),out); fclose(in); fclose(out);}A.程序完成将磁盘文件的信息在屏幕上显示的功能B.程序完成将两个磁盘文件合二为一的功能C.程序完成将一个磁盘文件复制到另一个磁盘文件中D.程序完成将两个磁盘文件合并后在屏幕上输出

点击查看答案

第5题

阅读下列程序,则在执行后,程序的运行结果为#include"stdio.h"#include"string.h"main(){ char a[

阅读下列程序,则在执行后,程序的运行结果为 #include"stdio.h" #include"string.h" main() { char a[30]="nice to meet you!"; strcpy(a+strlen(a)/2,"you"); printf("%s\n",a);}

A.nice to meet you you

B.nice to

C.meet you you

D.nice to you

点击查看答案

第6题

阅读下面的程序,当程序在执行时,如果输入的是 ’a’ ,则输出结果为 。 #include void main(); } }

A.abother letter

B.bbother letter

C.bother letter

D.abother letterb

点击查看答案

第7题

阅读下列程序段,则程序的输出结果为#include "stdio.h"#define M(X,Y)(X)*(Y)#define N(X,Y)(X)/(Y)main(){ int a=5,b=6,c=8,k;k=N(M(a,b),c);printf("%d\n",k);

A.3

B.5

C.6

D.8

点击查看答案

第8题

阅读以下说明和C语言函数,将应填入(n)处的语句写在对应栏内。【说明】 本程序利用非递归算法实现二

阅读以下说明和C语言函数,将应填入(n)处的语句写在对应栏内。

【说明】

本程序利用非递归算法实现二叉树后序遍历。

【函数】

include<stdio.h>

include<stdlib.h>

typedef struct node{/*二叉树的结点数据结构类型*/

char data;

struct node *left;

struct node *right;

}BTREE;

void SortTreelnsert(BTREE **tree, BTREE *s)

{

if(*tree==NULL)*tree=s;

else

if(s->data<(*tree)->data)

SortTreelnsert((1),s);

else if(s->data>=(*tree)->data)

SortTreelnsert((2),s);

}

void TraversalTree(BTREE *tree)

{

BTREE *stack[1 000],*p;

int tag[1000],top=0;

p=tree;

do{

while(p !=NULL)

{

stack[++top]=p;

(3);

tag[top]=0; /*标记栈顶结点的左子树已进行过后序遍历*/

}

while(top>0&&(4))/*栈顶结点的右子树是否被后序遍历过*/

{

p=stack[top--];

putchar(p->data);

}

if(top>0)/*对栈顶结点的右子树进行后序遍历*/

{

(5);

tag[top]=1;

}

}while(top>0);

}

void PrintSortTree(BTREE *tree)

{

if(tree !=NULL)

{

printSortTree(tree->left);

putchar(tree->data);

pdntSortTree(tree->right);

}

}

main()

{

BTREE *root=NULL, *node;

char ch;

ch=getchar();

while(ch !='')

{

node=(BTREE*)malloc(sizeof(BTREE));

node->data=ch;

node->left=node->right=NULL;

SortTreelnsert(&root, node);

ch=getchar();

}

PrintSortTree(root);

putchar('\n');

TraversalTree(root);

}

点击查看答案

第9题

有以下程序 #includemain(); } 程序运行后的输出结果是

A.-1,0

B.0,0

C.-1,-1

D.1,1

点击查看答案

第10题

有以下程序: #include void fun()

A.321678

B.876543

C.1098765

D.345678

点击查看答案

第11题

有以下程序 #include#includevoid fun(); } 程序运行后的输出结果是

A.012345

B.876543210

C.876543

D.012345678

点击查看答案
下载APP
关注公众号
TOP
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案 购买前请仔细阅读《购买须知》
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《服务协议》《购买须知》
立即支付 系统将自动为您注册账号
已付款,但不能查看答案,请点这里登录即可>>>
请使用微信扫码支付(元)

订单号:

遇到问题请联系在线客服

请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示:请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
请用微信扫码测试
优题宝