You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
943 B

#include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin >> x;
//是不是偶数
cout << (x % 2 == 0) << endl; //注意扩号的用法, 试试不加扩号行不行
//是不是为4位数
cout << (x >= 1000 && x <= 9999) << endl;
//是不是完全平方数
cout << ((int) sqrt(x) * (int) sqrt(x) == x) << endl;
cout << ((int) pow(x, 1.0 / 2) * (int) pow(x, 1.0 / 2) == x) << endl;
//是不是完全立方数、奇数、三位整数
cout << (x % 2 == 1 && (x >= 100 && x <= 999) &&
((int) pow(x, 1.0 / 3) *
(int) pow(x, 1.0 / 3) *
(int) pow(x, 1.0 / 3) == x)) << endl;
//水仙花数
cout << ((x >= 100 && x <= 999) &&
((x % 10) * (x % 10) * (x % 10) +
((x / 10) % 10) * ((x / 10) % 10) * ((x / 10) % 10) +
x / 100 * x / 100 * x / 100 == x)) << endl;
return 0;
}