目录
1、枚举
1)abc问题
2)反序数
3)对称平方数 1
4)与 7 无关的数
5)百鸡问题
6)Old Bill
2、模拟
1)输出梯形
2)叠筐
3)今年的第几天?
4)打印日期
5)日期累加
6)日期差值(上海交通大学复试上机题)
7)剩下的树(清华大学复试上机题)
8)手机键盘(清华大学复试上机题)
题目描述:
设 a, b, c 均是 0 到 9 之间的数字,abc, bcc 是两个三位数,且有 abc + bcc = 532。求满足条件的所有 a, b, c 的值。
Code:
#include
using namespace std;
int main()
{
int a,b,c;
for(a = 0;a < 10;a++){
for(b = 0;b < 10;b++){
for(c = 0;c < 10;c++){
if(a * 100 + b * 10 + c + b * 100 + c * 10 + c == 532)
cout<
题目描述:
设 N 是一个 4 位数,它的 9 倍恰好是其反序数(如 1234 的反序数是 4321),求N 的值。
#include
using namespace std;
int main()
{
int n,t,reverse;
for(n = 1000;n < 10000;n++){
t = n;
reverse = 0;
while(t != 0){
reverse = reverse * 10 + t % 10;
t /= 10;
}
if(n * 9 == reverse) cout<
题目描述:
打印所有不超过 256,其平方具有对称性质的数。如 2 和 11 就是这样的数,因为2*2 = 4,11*11 =121。
#include
using namespace std;
int main()
{
int n,t,reverse;
for(n = 0;n <= 256;n++){
t = n * n;
reverse = 0;
while(t != 0){
reverse = reverse * 10 + t % 10;
t /= 10;
}
if(n * n == reverse) cout<
题目描述:
一个正整数,如果它能被 7 整除,或者它的十进制表示法中某个位数上的数字为7,那么称其为与 7 相关的数。现求所有小于等于 n(n < 100)的与 7 无关的正整数的平方和。
#include
using namespace std;
int main()
{
int i,n,t,sum=0,flag = 1;
cin>>n;
for(i = 1;i <= n;i++){
flag = 1;
if(i % 7 == 0) continue;
t = i;
while(t != 0){
if(t % 10 == 7){
flag = 0;
break;
}
t /= 10;
}
if(flag)
sum += i * i;
}
cout<
题目描述:
用小于等于 n 元去买 100 只鸡,大鸡 5 元/只,小鸡 3 元/只,还有 1/3 元每只的一种小鸡,分别记为 x 只、y 只和 z 只。编程求解 x, y, z 所有可能的解。
#include
using namespace std;
int main()
{
int x,y,z,n;
cin>>n;
n *= 3;
for(x = 0;x <= 100;x++){
for(y = 0;y <= 100;y++){
for(z = 0;z <= 100;z++){
if(x + y + z == 100 && x * 15 + y * 9 + z <= n)
cout<<"x="<
题目描述:
N 只火鸡的价格为$ _XYZ_,火鸡的总数 N 在 1 到 99 之间。价格由五位数组成,两边的数字由于褪色而看不清,所以只能看到中间的三位数。假设第一个数字非零,每只火鸡的价格是整数,并且所有火鸡的价格相同