tgirc早修book
題目
#include<iostream>
using namespace std;
int main(){
int n;
cin >> n;
if(n % 2 ==0){
cout << "Even";
}
else{
cout << "Odd";
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int M, D, S;
cin >> M >> D;
S = (M * 2 + D) % 3;
if (S == 0){
cout << "普通\n";
}
else if (S == 1){
cout << "吉\n";
}
else {
cout << "大吉\n";
}
return 0;
}
#include<iostream>
using namespace std;
int main(){
int a, b, ans;
cin >> a >> b;
ans = b/2 - a/2;
ans += (a+1)%2;
cout << ans;
return 0;
}
#include<iostream>
using namespace std;
int main(){
int in, max=0;
for(int i = 0; i < 3; i++){
cin >> in;
if(in > max){
max = in;
}
}
cout << max;
return 0;
}
#include<iostream>
using namespace std;
int main(){
int hh, mm;
cin >> hh >> mm;
if(hh>=8 && hh<=16){
cout << "At School" << endl;
}
else if(hh == 7){
if(mm >= 30){
cout << "At School" << endl;
}
else{
cout << "Off School" << endl;
}
}
else{
cout << "Off School" << endl;
}
return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int a, b, c;
int x1, x2; //兩解
int d; //判別式
cin >> a >> b >> c;
d = sqrt( b*b - 4*a*c ); //判別式
if(d>0){ //判別式>0,兩實根
x1 = (-b + d) / (2*a);
x2 = (-b - d) / (2*a);
cout << "Two different roots x1=" << x1 << " , x2=" << x2;
}
else if(d == 0){ //判別式=0,重根
x1 = (-b) / (2*a);
cout << "Two same roots x=" << x1;
}
else{ //判別式<0,無實根
cout << "No real root";
}
return 0;
}
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up