你好哇,新的一天开始啦!
solution
取数值的不同部分,联想到借助string
#include<iostream>
#include<string>
using namespace std;
bool judge(string s){int n = atoi(s.c_str());if(n == 1 || n == 0) return false;for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;
}
int main(){string s;int flag = 1;cin >> s;while(s.size()){if(judge(s)) cout << s << " Yes" << endl;else{cout << s << " No" << endl;flag = 0;} s.erase(s.begin());}if(flag) cout << "All Prime!";return 0;
}