如题,有哪位大佬帮我看看哪里错了
而且案例1、2在电脑上试过了,都对
测试点也有案例1,就是不对
如果可以的话,还请更改一下
#include<iostream>
#include<string.h>
using namespace std;
inline bool ischar(char a[]){
int len = strlen(a);
int sum=0;
for(int i=0;i<len;++i){
if(a[i]<='0' || a[i]>='9'){
sum++;
}
}
if(sum==len) return 1;
else return 0;
}
inline bool isprime(int n){
for(int i=2;i*i<=n;++i){
if(n%i==0){
return 0;
}
}
return 1;
}
inline void zys(int n){
cout << n << "=";
for (int i = 2; i <= n; i++)
{
while (n % i == 0)
{
cout << i;
n /= i;
if (n != 1)
cout << "^";
}
}
}
int main(){
long long n=0;
char str[100005];
while(1){
cout<<"Enter the number=";
gets(str);
n=0;
int len = strlen(str);
if(ischar(str)) break;
else{
for(int i=0;i<len;++i){
if(str[i]>='0' && str[i]<='9'){
n = n*10+str[i]-'0';
}
}
}
cout<<"Prime? ";
if(n>=2 && isprime(n)) {
cout<<"Yes!"<<endl;
if(n>40000000){
cout<<"The number is too large!"<<endl;
cout<<endl;
continue;
}
cout<<endl;
continue;
}else{
if(n<2){
cout<<"No!"<<endl;
cout<<endl;
continue;
}else{
cout<<"No!"<<endl;
}
}
if(n>40000000){
cout<<"The number is too large!"<<endl;
cout<<endl;
continue;
}
zys(n);
cout<<endl;
cout<<endl;
}
return 0;
}