华师16-19真题

这篇博客包含了华师范大学16年至19年的计算机科学考试真题,涉及学生管理系统设计、递归函数、异常处理、链表操作、一元二次方程解法等知识点,同时涵盖类和对象的编程应用及文件操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

16年真题:
宿舍管理系统/学生管理系统
简单的学生管理系统

17年真题:

1.输入一个数字,为其高,一个符号*,输出该符号组成的平行四边形形状。

#include<fstream>
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
   
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
   
		for (int j = n - i; j >= 1; j--)
			cout << " ";
		for (int k = 1; k <= n; k++)
			cout << "*";
		cout << endl;
	}
		
	return 0;
}

2.是猴子吃桃问题,每天都吃剩下的一半,再多吃一个,直到第十天剩下一个桃子,问第一天猴子有多少个桃。

#include<fstream>
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
   
	int n;
	cin >> n;
	int sum = 0, t = 1;
	for (int i = 1; i < n; i++)
	{
   
		sum = (t + 1) * 2;
		t = sum;
	}
	cout << sum << endl;
	return 0;
}

3.输入一系列的数字,输出他们正负数个数,输入0截止,要用函数实现 。


#include<fstream>
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;

void fun()
{
   
	int a = 0, b = 0, n;
	while (cin >> n)
	{
   
		if (n == 0)
			break;
		if (n > 0)a++;
		else if (n < 0)b++;
	}
	cout << "正数个数:" << a << endl;
	cout << "负数个数:" << b << endl;
}
int main()
{
   
	fun();
	return 0;
}

4.是用一个类来记录学生成绩和他班级,里面有几个函数,静态成员和动态成员都有。



#include<fstream>
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;

class Student {
   
private:
	string num;
	string name;
	string class_;
	float score;
	static int cnt;
	static float sum;
	static float ave;
public:
	Student(string n,string na,string c,float s)
	{
   
		num = n;
		name = na;
		class_ = c;
		score = s;
		cnt++;
		sum = sum + s;
	}
	static float average() {
   
		ave = sum / cnt;
		return ave;
	}
	static float getTotal()
	{
   
		return sum;
	}
	void getData()
	{
   
		cout << "输出 学号 姓名 班级 成绩:" << endl;
		cout << "num: " << num << endl;
		cout << "name: " << name << endl;
		cout << "class: " << class_ << endl;
		cout << "score: " << score << endl;
	}
};
 float Student::ave = 0;
 float Student::sum = 0;
 int Student::cnt = 0;

int main()
{
   
	Student Stu[5] = {
   
		Student("101","小明","十班",89.5),
		Student("102","Mike","十班",77.5),
		Student("103","Jackson","十班",87.0),
		Student("104","Cherry","十班",93.5),
		Student("105","Oscar","十班",89.0)
	};
	cout << "总分:" << Student::getTotal() << endl;
	cout << "平均分:" << Student::average() << endl;

	return 0;
}


5.重载+,++,=等简单运算符
时间相加减


#include <iostream>
#include<algorithm>
#include<string>
using namespace std;

class Time {
   
private:
	int sec;
	int min;
public:
	//构造函数
	Time(int m = 0, int s = 0)
	{
   
		min = m;
		sec = s;
	}
	void operator=(Time a)
	{
   
		min = a.min;
		sec = a.sec;
	}
	friend ostream & operator<<(ostream & out, Time& a)
	{
   
		out << a.min << "/" << a.sec << endl;
		return out;
	}
	Time operator+(Time &a);
	Time operator++();//前置
	Time operator++(int);//后置
	
};
Time Time::operator+(Time &a)
{
   
	Time c;
	c.min = a.min + min;
	c.sec = a.sec + sec;
	if (c.sec >= 60)
	{
   
		c.sec -= 60;
		c.min++;
	}
	return c;
}
Time Time::operator++()
{
   
	sec++;
	if (sec >= 60)
	{
   
		sec -= 60;
		min++;
	}
	return *this;
}
Time Time::operator++(int)
{
   
	Time t = *this;
	sec++;
	if (sec >= 60)
	{
   
		sec -= 60;
		min++;
	}
	return t;
}

int main()
{
   
	Time a;
	cout << "a:";
	cout << a << endl;
	a++;
	cout << "a++:";
	cout << a << endl;
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值