江苏科技大学课程考试参考答案及评分标准(A)
课程名称:《计算机程序设计语言(VC)》 开课学期:2023--2024学年第2学期
、选择题(每题2分,共20分)
题号 / 2 3 5 6 7 8 9 10答案C D D B A B C D A
二、填空题(每空2分,共50分)(每空有2个以上答案时,可分开给分)
(1) 2 (2) 1(3) 保护或protected (4) 友元(5) 8 13 (9) 8 16 2(7) 10.15.5 (8) 10.15.5(9) 0 (01) 15(11) 120 (12) 10(13) class A (14) 20 30(15) A() (16) C()(17) 24 2 4 10 (18) n%i-0等(19) in等 (20) p2[num]等(21) fun(t.4.p)等 (22) COMPLEX operator0(23) *this (24) COMPLEX operator(25) c2
三、编程题(第1题10分,第2题20分,共30分)
[第1题参考答案](本题10分)
#includeint mainO using namespace std;float x y s;<<x<<s=xy; cout<<s<<endl;return 0; 1、程序基本格式和规范:2分2、函数定义:2分3、变量定义:2分 4、变量输入:2分5、变量输出:2分 [第2题参考答案](本题20分)#include 第2题评分标准using namespace std; class STR{ 1、类的定义(格式和和成员说明):3分char *str; 2、成员初始化(构造函数):3分public: 4、动态空间释放(构造函数):2分 3、成员输出(print函数):2分STR(char *s) 5、字符串排序算法(fun函数):6分str=new char[strlen(s)1]; 6、定义测试数据(初始化或赋值):1分strcpy(str s); 7、建立对象:1分8、测试(调用成员函数):2分void funOchar *p1=str *p2 t;while(*(p11)){p2=p11; while(*p2){if(*pl<*p2)t=*p1 *p1=*p2 *p2=t;p2;} pl;}}void printO (cout<<str<<endl; ~STR(delete [str int main( )char t[100];cin.getline(t 100); cout<<"请输入一个字符串:in";STR test(t);cout<<"原字符串为:n";test.printO);cout<<"排序后的字符串为:n"; test.funO;test.printO;return O;}