东华考研复试11-20oj

11.成绩转换

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	int n;
	string ch;
	while(cin>>n){
		if (n <= 100 && n >= 90) {
			ch = "A";
		} else if(n <= 89 && n >= 80) {
			ch = "B";
		} else if (n <= 79 && n >= 70) {
			ch = "C";
		} else if (n <= 69 && n >= 60) {
			ch = "D";
		} else if (n <= 59 && n >= 0) {
			ch = "E";
		} else {
			ch = "Score is error!";
		}
		cout<<ch<<endl;
	}
		
	return 0;
}

12.求第几天

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	int y,m,day,total = 0;
	while(cin>>y>>m>>day){
		if (y % 400 == 0 || (y%100 != 0 && y % 4 == 0)) {
		switch(m) {
			case 1:
            total=day;
            break;
        case 2:
        	total=day+31;
            break;
        case 3:
            total=day+31+29;
            break;
        case 4:
            total=day+31+29+31;
            break;
        case 5:
            total=day+31+29+31+30;
            break;
        case 6:
            total=day+31+29+31+30+31;
            break;
        case 7:
            total=day+31+29+31+30+31+30;
            break;
        case 8:
            total=day+31+29+31+30+31+30+31;
            break;
        case 9:
            total=day+31+29+31+30+31+30+31+31;
            break;
        case 10:
            total=day+31+29+31+30+31+30+31+31+30;
            break;
        case 11:
            total=day+31+29+31+30+31+30+31+31+30+31;
            break;
        case 12:
            total=day+31+29+31+30+31+30+31+31+30+31+30;
            break;
		}
		} else {
				switch(m) {
			case 1:
            total=day;
            break;
        case 2:
        	total=day+31;
            break;
        case 3:
            total=day+31+28;
            break;
        case 4:
            total=day+31+28+31;
            break;
        case 5:
            total=day+31+28+31+30;
            break;
        case 6:
            total=day+31+28+31+30+31;
            break;
        case 7:
            total=day+31+28+31+30+31+30;
            break;
        case 8:
            total=day+31+28+31+30+31+30+31;
            break;
        case 9:
            total=day+31+28+31+30+31+30+31+31;
            break;
        case 10:
            total=day+31+28+31+30+31+30+31+31+30;
            break;
        case 11:
            total=day+31+28+31+30+31+30+31+31+30+31;
            break;
        case 12:
            total=day+31+28+31+30+31+30+31+31+30+31+30;
            break;
		}
		}      
	
		cout<<total<<endl;
	}		
	return 0;
}


13.求阶乘结果0的个数

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int fi(int l)
{
    int b=0;
    while(l>=5)
    {
        l/=5;
        b+=l;
    }
    return b;
}
int main()
{
    int n;   
    while(cin>>n)
    {
        int t=fi(n);
        cout<<t<<endl;
    }
    return 0;
}

14.怪数

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int fi(int a) {
	int sum = 0;
	for (int i = 1; i < a; i++) {
		if(a %  i == 0) {
			sum += i;
		}	
	}
	if (sum == a) {
		return 1;
	} else return 0;
}

int main() {
	int n, i = 2;
	while(cin>>n){
		while (i <= n) {
			i++;
			if(fi(i)){
				cout<<i<<endl;
			}
		}	
	}		
	return 0;
}

15.abc数字

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	int a,b,c,l,r,s;
	while(cin>>a>>b>>c){
                int count = 0;
		l = a * 100 + b * 10 + c;
		r = c * 100 + b * 10 + a;
		s = l * r;
		for (int i = s;i > 0;i /=10) {
			int j = i / 10;
			int k = i - j*10; 
			if (k == a || k == b || k == c){
				count++;
			}
		}
		cout << s << " "<<count<<endl;
	}		
	return 0;
}

16.奇妙的比值

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	int n;
	double sum = 0;
	while(cin>>n){
		sum = 0;
		for (int i = 1; i <= n; i++) {
			if (n % i == 0) {
				sum += i;
			}
		}
		sum /=n;
		cout << fixed <<setprecision(2) << sum <<endl;
	}		
	return 0;
}

17.T的倍数N

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int isTarget(int n, int T) {
	int tras = 0;
	int stack[7] = {0};
	int top = -1;
	int temp = n;
	
	
	tras += n % 10;
	n /= 10;
	
	while (n) {
		stack[++top] = n % 10;
		n /= 10;
	}
	
	while (top != -1) {
		tras = tras * 10 + stack[top];
		top--;
	}
	
	if ((double)tras / (double)temp == T) {
		return 1;
	} 
	else {
		return 0;
	}
}



int main() {
	int n , i = 0;
	while(cin>>n){
		for (i = 1; i<=1000000; i++){
			if ((i % 10 == 7) && (isTarget(i, n) == 1)) {
				cout<<i<<endl; break;
			}
		}
		if (i == 1000001) {
			cout<<"No"<<endl;	
		}
					
	}		
	return 0;
}

18.三角形

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
 int a, b;
 while(cin>>a>>b) {
  for (int i = 0; i < b; i++) {
   for (int j = 0; j < i; j++) {
    if (a == 9) {
     cout<<a<<" ";
     a = 1;
    } else {
     cout<<a<<" ";
     a++;
    }
   }
   if(a == 9) {
    cout<<a;
    a = 1;
   } else {
    cout<<a;
    a++;
   }
   cout<<endl;
  }    
 }  
 return 0;
}

19.数字串处理

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	int a[100], b, n, key,count,temp,i;
	while(cin>>n) {
		count = 1;
		for (i = 0;i < n;i++) {
			cin>>a[i];
		}
		key = a[0];	
		temp = 1;
		for (i = 1; i < n; i++) {
			if (a[i] == a[i - 1]) temp++;
			else{
				if(temp > count) {
					count = temp;
					key = a[i - 1];
					temp = 1;
				} else {
					temp = 1;
				}
			}
			
			}if(temp > count) {
				count = temp;
				key = a[i - 1];
		}
		cout<<key<<" "<<count<<endl;			
	}		
	return 0;
}


20.公式求解

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	int a,b;
	while(cin>>a>>b) {
		if(a==0&b==0){
			break;
		}
	for (int x = 1;x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			if(a * a + x * x == b * b + y * y) {
				cout<<x<<" "<<y<<endl;
				break;
			}
		}
	}
	cout<<endl;			
	}		
	return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值