2000年北理计算机复试上机

题目来源:https://blog.csdn.net/u014552756/article/details/57427906
代码原创

1.倒序输出

#include
using namespace std;
int main(){
	string s;
	while(getline(cin, s)){
		for(int i = s.length()-1; i > 0; i--)
			cout << s[i];
		cout << s[0] << endl;
	}
	return 0;
} 

2000年北理计算机复试上机_第1张图片
2.abc

#include
using namespace std;
int main(){
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < 10; k++){
				if((i+j)*100 + (j+k)*10 + 2*k == 532){
					cout << "a = " << i << " b = "<<j <<" c = " << k <<endl; 
				}
			}
		}
	}
	return 0;
}

2000年北理计算机复试上机_第2张图片
3.完数盈数

#include
using namespace std;

int main(){
	vector<int> wan;
	vector<int> ying;
	for(int i = 2; i <= 60; i++){
		vector<int> num;
		for(int j = 2; j <= i/2; j++){
			if( i % j == 0){
				num.push_back(j);
			}
		}
		int sum = 1;
		for(int k = 0; k < num.size(); k++){
			sum += num[k];
		}
		if(sum == i){
			wan.push_back(i);
		}else if(sum > i){
			ying.push_back(i);
		}
	}
	cout<<"E: ";
	for(int i = 0; i < wan.size(); i++){
		cout<<wan[i]<<" ";
	}
	cout << endl;
	cout <<"G: ";
	for(int i = 0; i < ying.size(); i++){
		cout << ying[i] << " ";
	}
	cout << endl;
	return 0;
}

2000年北理计算机复试上机_第3张图片

你可能感兴趣的:(北理复试上机)