1.成绩
#include<bits/stdc++.h> using namespace std; int main() { int grade; cin>>grade; if (grade>=85) cout<<'A'<<endl; else if(grade>=70) cout<<'B'<<endl; else if(grade>=60) cout<<'C'<<endl; else cout<<'D'<<endl; return 0; }
2.加减乘除
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
char c;
cin >> a >> b >> c;
if(c == '+') cout << a+b <<endl;
else if(c == '-') cout << a-b << endl;
else if( c =='*') cout << a*b << endl;
else if( c== '/', b == 0)
cout << "Divided by zero!"<<endl;
else cout << "Invaild operator!"<<endl;
return 0;
3.闰年的计算
#include <bits/stdc++.h>
using namespace std;
int main()
{
int year;
cin >> year;
if(year %100 ==0)
{
if(year%400==0)
cout << "yes" <<endl;
}
else
if(year%4==0) cout<<"yes"<<endl;
else cout<<"No"<<endl;
return 0;
}