c++final exam test 1//20191221

#include<iostream>//15
using namespace std;
int sub(int);
int main()
{
    int  i = 5;
    cout << sub(i) << endl;
}
int sub(int  n)
{
    int  a;
    if (n == 1)   return  1;
    a = n + sub(n - 1);
    return   a;
}
#include<iostream>//print->012345543210
using namespace std;//因为你的if语句前面和后面一共用了两个cout所以会输出两组数据
void recur(char c)
{
    cout << c;
    if (c <'5') recur(c + 1);
    cout << c;
}
int main(void)
{
    recur('0');
}

#include<iostream>//1221
using namespace std;
int main()
{
	int m = 1, n = 2;
	int* p = &m, * q = &n, * r;
	r = p; p = q; q = r;
	cout << m << n << *p << *q << endl;
}

#include<iostream>//d
using namespace std;
void fun(char *s)
{   while(*s)
  {
     if(*s%2==0)
        cout<<*s;
     s++;
  }
}
void main()
{   char a[]="good ";
     fun(a);
}
#include <iostream>
using namespace std;
void fun(int a = 4, int b = 12, int c = 13)
{
	cout << a << ',' << b << ',' << c << endl;
}
void main()
{
	fun(); fun(8);
}
#include <iostream>
using namespace std;
void main()
{
	int b[][3] = { {1,5,6},{3},{0,2} };
	cout << b[1][1];
}
#include <iostream>//是否相等的正确表达式->strcmp
#include<string.h>
using namespace std;
void main()
{
	char s1[] = "ch2na";//china
	char s2[]= "china";
	cout << (s1 == s2) << endl;
	cout << strcmp(s1, s2);
}
#include <iostream>   //1  区分上面,char与string类型
#include <string>   
using namespace std;
int main()
{
	string  a = "boot" , b = "book";
	if (a == b)  cout << '1' << endl;
	else  cout << '0' << endl;
	return  0;
}
#include <iostream>
#include<string.h>
using namespace std;
void main()
{
	char s1[] = "abcd";//✔
	char s4[2][3] = { "xyz","mnp" };//❌
	char s3[][3] = { 'a' , 'x' , 'y' };//❌第一维的长度是不定的,s[3][]=xx,正确
	char s2[3] = "xyz";//❌
}
#include<iostream>//oC+
#include<string>
using namespace std;
int main()
{
	string str = " HelloC++!";
	cout << str.substr(5, 3) << endl;
}
#include<iostream>//5  20
#include<string>
using namespace std;
int main()
{
	char a[20] = "CHINA";
	cout << strlen(a) << "  " << sizeof(a) << endl;
}
#include<iostream>//待解决,strcpy()函数问题
#include<string>
#include<stdlib.h>
using namespace std;
int main()
{
	char a[7] = "abcdef";
	char b[4] = "ABC";
	strcpy(a, b);
	cout << a[5] << endl;
}

#include <iostream> //求二(三)维方阵主对角线元素之和 此处/**/表填空
#include <string>   
using namespace std;
int main()
{
	int a[3][3] = { 9,8,7,6,5,4,3,2,1 }, s = 0;
	/*for (int i = 0; i < 3; i++)
		for (int j = 0; j< 3; j++)
		{
			if (i == j)
				s += a[i][j];
		}*/
		
	cout << s << endl;
}
#include <iostream>  //以下程序用于从键盘上输入若干个学生的成绩,统计出平均成绩,
#include <string>   //并输出低于平均成绩的学生成绩。输入负数结束 
using namespace std;
int main()
{
	float  x[100], sum = 0, ave, a;
	int n = 0, i;
	cout << "Input score\n";
	cin>>a;/**/
	while (a>=0.0 && n<1000)
	{
		x[n] = a;
		sum+=a;/**/
		n++;/**/
		cin >> a;
	}
	ave = sum / n;//sum/n或sum/(float)n或sum/(double)n
	cout << "ave = " << ave << endl;
	for (i = 0; i < n; i++)/**/
	{
		if (x[i] < ave)//x[i]<ave或!(x[i]>=ave)或ave>x [i]/**/
			cout << "x[" << i << "]"<< x[i] << endl;
	}
}
#include<iostream>//200
using namespace std;
int main()
{
	int hot = 100;
	int& rad = hot;
	hot += 100;
	cout << rad << endl;
}
	
#include<iostream>//48
using namespace std;
void main()
{
	int a[2][3] = { {1,2,3},{4,5,6} };
	int k, * p;
	p = a[0] + 1;
	k = (*p) * (*(p + 2)) * (*(p + 4));
	cout << k << endl;
}
	
#include<iostream>//a 下标从0开始
using namespace std;
int main()
{
	string a = "beautiful";
	cout << a[2];
}
	
#include <iostream>//输入helloworld
#include <string>
using namespace std;
int main()
{
	string str;
	cout << "请输入一个字符串:"; getline(cin, str);
	cout << str[2] << str[5] << endl;//lw
	str[5] = '\0';
	cout << str << endl;//hello ord(中间空的)
	return 0;
}
#include<iostream>//输入 12  5  9 打印26
using namespace std;
void main()
{
int a,b,c,s=0;
int *p[3]={&a,&b,&c};
for(int i=0;i<3;i++)
cin>>*p[i];
for(i=0;i<3;i++)
s=s+*p[i];
cout<<s<<endl;
}
#include "iostream"//构造函数与析构函数***
#include<iostream >
using namespace std;
class AA
{
public:
	AA() { cout << '1' << ""; }
	~AA() { cout << "2" << ""; }
};
class BB : public AA
{
	int k;
public:
	BB(int n) :k(n) { cout << k << ""; }
	~BB() { cout << "4" << ""; }
};
int  main()
{
	BB b(6);
	return 0;
}
#include<iostream>
using namespace std;
#define MAX  5
int main()
{
	int a[MAX + 1], x, i;
	for (i = 1; i <= MAX; i++)
		cin >>a[i];
	cout << "Enter x : ";
	cin >> x;
	a[0] = x;  i = MAX;
	while (x != i)
		i--;
	if (x==i)
		cout << x << "位置:" << i << endl;
	else
		cout << "Not found" << endl;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
c test/parasoft是一个软件测试工具,旨在帮助开发者提高软件的质量和可靠性。同时,也能够帮助开发者减少测试时间和成本。 Parasoft是一个知名的软件测试解决方案提供商,其提供了一系列的测试工具和服务。其中,c test是Parasoft的一个产品,主要用于C/C++代码的静态分析和测试。 c test/parasoft具有以下特点和功能: 1. 静态分析能力:c test/parasoft可以通过静态分析技术检测代码中的潜在问题和缺陷,例如内存泄漏、空指针引用等,帮助开发者在代码编写阶段即发现和修复问题,减少后续测试和维护的工作量。 2. 自动化测试:c test/parasoft提供了自动化测试工具,可以自动生成测试用例,执行测试,并对测试结果进行分析和报告。它可以帮助开发者快速发现代码中的问题和错误,提高软件的质量。 3. 代码覆盖分析:c test/parasoft可以分析代码覆盖率,帮助开发者了解测试用例是否覆盖了源代码中的所有分支和路径。这样可以确保测试的全面性和有效性。 4. 安全性分析:c test/parasoft可以进行安全性分析,检测潜在的安全漏洞和风险,帮助开发者提前发现和解决安全问题。 5. 效能分析:c test/parasoft还可以进行性能分析,帮助开发者识别代码中的性能瓶颈和优化点,提高软件的性能和效能。 总之,c test/parasoft是一个功能强大的软件测试工具,可以帮助开发者提高代码质量,加快测试过程,降低测试成本。它在软件开发过程中起到了非常重要的作用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值