高分跪求一份有关C++的试卷!!!50分期价,好的加200!!!

1、 C++简单数据类型有___________________________________
2、 将信息“Hello”输出到屏幕上的语句是________________________
3、 将键盘输入的信息存入变量a的语句是_________________________
4、 我们所学的C++程序从___________函数开始执行,它是程序的入口。
5、 三种基本程序结构是 、 、 。
6、 算术运算符有____________________________
7、 关系运算符有____________________________
8、 逻辑运算符有____________________________
9、 表达式指________________________________
10、 C++中__________是语句结束的标志

二、简答 (每小题5分,共10分)
分支语句的格式:(2分)

循环语句的格式:(3分)

三、读程序,写结果(每小题 5 分,共 40 分)
1、
#include “stdio.h”
int main()
{
int x, y, max;
x=3;
y=6;

if (x>y)
max = x;
else
max = y;
printf(“max=%d\n",max);
return 0;
}
输出结果:

2、
#include "stdio.h"
void main()
{
int w[5]={ 1,2,3,4,5 };
int i=0;
printf("%d,", w[i++]);
printf("%d\n",w[++i]);
}
输出结果:

3、
#include "stdio.h"
void main()
{
int w[10], i;
for (i=0; i<10; i++)
w[i] = 3*i;
for (i=9; i>=0; i++)
printf("%d ", w[i]);
}
输出结果:

4、
#include "stdio.h"
void main()
{
int w[10], i;
for (i=0; i<10; i++)
w[i] = 3*i;
for (i=9; i>=0; i--)
{
w[i] += 1;
printf("%d ", w[i]);
}
}
输出结果:

5、
#include <stdio.h>
swap(int a,int b)
{
int temp;
temp=a; a=b; b=temp;
}
void main()
{
int x=7,y=11;
printf("x=%d,\ty=%d\n",x,y);
printf("swapped:\n");
swap(x,y);
printf("x=%d,\ty=%d\n",x,y);
}
输出结果:

6、
#include "stdio.h"
void main()
{
char *s = "13579";
*s++;
printf("%c%c%c", *s, *(s+1), *s+1);
}
输出结果:

7、
#include <stdio.h>
void main()
{
int i;
int f[20]={1,1};
for(i=2;i<20;i++)
f[i]=f[i-2]+f[i-1];
for(i=0;i<20;i++)
{
if(i%5==0) printf("\n");
printf("%12d",f[i]);
}
}
输出结果:

8、
#include "stdio.h"
int a=4, b=5;
int fun(int x, int y)
{
int a=2, b=3, c;
c=a>b?a:b;
return c+x+y;
}

void main()
{
printf("%d\n", fun(a,b));
}
输出结果:

四、编程序(每小题15分,共30 分)
1、输出Fibonacci数列的前20项和

2、结构体的定义及使用(15分)
定义结构体类型BOOK,描述一本书的信息
name author pages
size price

h v
name: 书名,字符数组(char [])
author: 作者,字符数组(char [])
pages: 页数,整型(int)
size: 纸张大小,DIMENSION类型(结构体类型变量,见下面具体描述)
pirce: 价格,单精度浮点型(float)

DIMENSION
h v
h: 宽度,单精度浮点型(float)
v: 高度,单精度浮点型(float)

定义BOOK类型的变量bk,将如下信息写入bk
书名为《C++ Programing》,作者是M.Kelody,全书共108页,纸张大小为16*14,价格为28.6元。

最后一道题 2、结构体的定义及使用(15分)表格沾不上来,能看懂的高手尽量做吧,谢了,如果包正加分到200

1、 C++简单数据类型有___整型、字符型、浮点型、布尔型、空类型
2、 将信息“Hello”输出到屏幕上的语句是____cout<<”Hello<<endl;
3、 将键盘输入的信息存入变量a的语句是_____cin>>a
4、 我们所学的C++程序从__main__函数开始执行,它是程序的入口。
5、 三种基本程序结构是 顺序结构、选择结构、循环结构
6、 算术运算符有__+,-,*,/,%,++,--
7、 关系运算符有___>,<,>=,<=,==,!=
8、 逻辑运算符有___!,&&,||
9、 表达式指__值或者值和操作符的组合
10、 C++中_分号__是语句结束的标志

二、简答 (每小题5分,共10分)
分支语句的格式:(2分)
switch(表达式)
{case 常量表达式1:语句1
case 常量表达式2:语句2
……
case 常量表达式n:语句n
default: 语句n+1
}
循环语句的格式:(3分)
第一种:while(表达式)语句
第二种:do
语句
While(表达式);
第三种:for(表达式1;表达式2;表达式3)
语句
三、读程序,写结果(每小题 5 分,共 40 分)
1、
#include “stdio.h”
int main()
{
int x, y, max;
x=3;
y=6;

if (x>y)
max = x;
else
max = y;
printf(“max=%d\n",max);
return 0;
}
输出结果:max=6
//它这里是叫你输出x跟y中较大的数

2、
#include "stdio.h"
void main()
{
int w[5]={ 1,2,3,4,5 };
int i=0;
printf("%d,", w[i++]);
printf("%d\n",w[++i]);
}
输出结果:
1,3
//第一次printf,i是先先输出w【i】再加1;第二次是先+1,再输出w【i】,换言之第二次是输出i【2】;

3、
#include "stdio.h"
void main()
{
int w[10], i;
for (i=0; i<10; i++)
w[i] = 3*i;
for (i=9; i>=0; i++) //i++变i--
printf("%d ", w[i]);
}
输出结果:27 24 21 18 15 12 9 6 3 0
//这道题目有错,我改在上面了

4、
#include "stdio.h"
void main()
{
int w[10], i;
for (i=0; i<10; i++)
w[i] = 3*i;
for (i=9; i>=0; i--)
{
w[i] += 1;
printf("%d ", w[i]);
}
}
输出结果:
28 25 22 19 16 13 10 7 4 1
5、
#include <stdio.h>
swap(int a,int b)
{
int temp;
temp=a; a=b; b=temp;
}
void main()
{
int x=7,y=11;
printf("x=%d,\ty=%d\n",x,y);
printf("swapped:\n");
swap(x,y);
printf("x=%d,\ty=%d\n",x,y);
}
输出结果:
//这道题有点怪异,它那个swap函数明明是想将a跟b掉转的,但swap(x,y)使用时并x,y只是参数传递过去swap,对原本的a和b没有影响,原题的答案是
X=7,y=11
Swapped:
X=7,y=11
除非将第二行改为void swap(int &a,int &b),
答案就会变成:
X=7,y=11
Swapped:
X=11,y=7

6、
#include "stdio.h"
void main()
{
char *s = "13579";
*s++;
printf("%c%c%c", *s, *(s+1), *s+1);
}
输出结果:
354

7、
#include <stdio.h>
void main()
{
int i;
int f[20]={1,1};
for(i=2;i<20;i++)
f[i]=f[i-2]+f[i-1];
for(i=0;i<20;i++)
{
if(i%5==0) printf("\n");
printf("%12d",f[i]);
}
}
输出结果:
1 1 2 3 5
8 13 21 34 55
89 144 233 377 610
987 1597 2581 4181 6765
(为什么提交后就对不齐呢??总之每竖行的数都是右对齐啊,然后每个数与它前面的空格数的和都是12,不明白再问我吧)
8、
#include "stdio.h"
int a=4, b=5;
int fun(int x, int y)
{
int a=2, b=3, c;
c=a>b?a:b;
return c+x+y;
}

void main()
{
printf("%d\n", fun(a,b));
}
输出结果:
12

四、编程序(每小题15分,共30 分)
1、输出Fibonacci数列的前20项和
#include "stdio.h"

void main()
{
int a[20];
a[0]=0;a[1]=1;
for(int i=2;i<20;i++)
a[i]=a[i-1]+a[i-2];
for(int i=0;i<20;i++)
printf("%d\n", a[i]);
}
//鉴于本人其实不会c语言……只会c++,所以只能每个数之间都回车,你可以把它变成空格的。不过~~不许怀疑我上面的正确率,都是正确的。

2、结构体的定义及使用(15分)
定义结构体类型BOOK,描述一本书的信息
name author pages
size price

h v
name: 书名,字符数组(char [])
author: 作者,字符数组(char [])
pages: 页数,整型(int)
size: 纸张大小,DIMENSION类型(结构体类型变量,见下面具体描述)
pirce: 价格,单精度浮点型(float)

DIMENSION
h v
h: 宽度,单精度浮点型(float)
v: 高度,单精度浮点型(float)

定义BOOK类型的变量bk,将如下信息写入bk
书名为《C++ Programing》,作者是M.Kelody,全书共108页,纸张大小为16*14,价格为28.6元。

#include<iostream>
using namespace std;//你少了这两行东东,这两行是输入流的预处理
struct DIMENSION
{
float h;
float v;
void Ret()
{
cout<<"input height:";scanf("%d",&h);
cout<<"input wideth:";scanf("%d",&v);
}
};
struct BOOK//呵呵, 我一般不调试的话都会打错struct这个词,my fault
{
char name[10];
char author[10];//原来字符数组里面要加数字的,你看看10个字符写作者名够不够吧,如果不够的话就自己改那个数字吧
int pages;
DIMENSION size;
float price;
void Ret()
{
cout<<"input name:";scanf("%d",&name);
cout<<"input author:";scanf("%d",&author);
cout<<"input pages:";scanf("%d",&pages);
size.Ret();
cout<<"input price";scanf("%d",&price);
}
};
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-01-14
、 C++简单数据类型有___整型、字符型、浮点型、布尔型、空类型
2、 将信息“Hello”输出到屏幕上的语句是____cout<<”Hello<<endl;
3、 将键盘输入的信息存入变量a的语句是_____cin>>a
4、 我们所学的C++程序从__main__函数开始执行,它是程序的入口。
5、 三种基本程序结构是 顺序结构、选择结构、循环结构
6、 算术运算符有__+,-,*,/,%,++,--
7、 关系运算符有___>,<,>=,<=,==,!=
8、 逻辑运算符有___!,&&,||
9、 表达式指__值或者值和操作符的组合
10、 C++中_分号__是语句结束的标志

二、简答 (每小题5分,共10分)
分支语句的格式:(2分)
switch(表达式)
{case 常量表达式1:语句1
case 常量表达式2:语句2
……
case 常量表达式n:语句n
default: 语句n+1
}
循环语句的格式:(3分)
第一种:while(表达式)语句
第二种:do
语句
While(表达式);
第三种:for(表达式1;表达式2;表达式3)
语句
三、读程序,写结果(每小题 5 分,共 40 分)
1、
#include “stdio.h”
int main()
{
int x, y, max;
x=3;
y=6;

if (x>y)
max = x;
else
max = y;
printf(“max=%d\n",max);
return 0;
}
输出结果:max=6
//它这里是叫你输出x跟y中较大的数

2、
#include "stdio.h"
void main()
{
int w[5]={ 1,2,3,4,5 };
int i=0;
printf("%d,", w[i++]);
printf("%d\n",w[++i]);
}
输出结果:
1,3
//第一次printf,i是先先输出w【i】再加1;第二次是先+1,再输出w【i】,换言之第二次是输出i【2】;

3、
#include "stdio.h"
void main()
{
int w[10], i;
for (i=0; i<10; i++)
w[i] = 3*i;
for (i=9; i>=0; i++) //i++变i--
printf("%d ", w[i]);
}
输出结果:27 24 21 18 15 12 9 6 3 0
//这道题目有错,我改在上面了

4、
#include "stdio.h"
void main()
{
int w[10], i;
for (i=0; i<10; i++)
w[i] = 3*i;
for (i=9; i>=0; i--)
{
w[i] += 1;
printf("%d ", w[i]);
}
}
输出结果:
28 25 22 19 16 13 10 7 4 1
5、
#include <stdio.h>
swap(int a,int b)
{
int temp;
temp=a; a=b; b=temp;
}
void main()
{
int x=7,y=11;
printf("x=%d,\ty=%d\n",x,y);
printf("swapped:\n");
swap(x,y);
printf("x=%d,\ty=%d\n",x,y);
}
输出结果:
//这道题有点怪异,它那个swap函数明明是想将a跟b掉转的,但swap(x,y)使用时并x,y只是参数传递过去swap,对原本的a和b没有影响,原题的答案是
X=7,y=11
Swapped:
X=7,y=11
除非将第二行改为void swap(int &a,int &b),
答案就会变成:
X=7,y=11
Swapped:
X=11,y=7

6、
#include "stdio.h"
void main()
{
char *s = "13579";
*s++;
printf("%c%c%c", *s, *(s+1), *s+1);
}
输出结果:
354

7、
#include <stdio.h>
void main()
{
int i;
int f[20]={1,1};
for(i=2;i<20;i++)
f[i]=f[i-2]+f[i-1];
for(i=0;i<20;i++)
{
if(i%5==0) printf("\n");
printf("%12d",f[i]);
}
}
输出结果:
1 1 2 3 5
8 13 21 34 55
89 144 233 377 610
987 1597 2581 4181 6765
(为什么提交后就对不齐呢??总之每竖行的数都是右对齐啊,然后每个数与它前面的空格数的和都是12,不明白再问我吧)
8、
#include "stdio.h"
int a=4, b=5;
int fun(int x, int y)
{
int a=2, b=3, c;
c=a>b?a:b;
return c+x+y;
}

void main()
{
printf("%d\n", fun(a,b));
}
输出结果:
12

四、编程序(每小题15分,共30 分)
1、输出Fibonacci数列的前20项和
#include "stdio.h"

void main()
{
int a[20];
a[0]=0;a[1]=1;
for(int i=2;i<20;i++)
a[i]=a[i-1]+a[i-2];
for(int i=0;i<20;i++)
printf("%d\n", a[i]);
}

2、结构体的定义及使用(15分)
定义结构体类型BOOK,描述一本书的信息
name author pages
size price

h v
name: 书名,字符数组(char [])
author: 作者,字符数组(char [])
pages: 页数,整型(int)
size: 纸张大小,DIMENSION类型(结构体类型变量,见下面具体描述)
pirce: 价格,单精度浮点型(float)

DIMENSION
h v
h: 宽度,单精度浮点型(float)
v: 高度,单精度浮点型(float)

定义BOOK类型的变量bk,将如下信息写入bk
书名为《C++ Programing》,作者是M.Kelody,全书共108页,纸张大小为16*14,价格为28.6元。

strut DIMENSION
{
float h;
float v;
void Ret()
{
cout<<"input height:";cin<<h;
cout<<"input wideth:";cin<<v;
}
};
strut BOOK
{
char name[];
char author[];
int pages;
DIMENSION size;
float price;
void Ret()
{
cout<<"input name:";cin<<name;
cout<<"input author:";cin<<author);
cout<<"input pages:";cin<<pages;
size.Ret();
cout<<"input price";cin<<price;
};
相似回答
大家正在搜