hdu 1405 Runtime Error(INTEGER_DIVIDE_BY_ZERO) 各位大牛帮帮小弟 ,也没有除过0啊
#include<iostream>usingnamespacestd;intmain(){inta,b,c;longi,j,k;inttemp;intnum;intzh...
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
long i,j,k;
int temp;
int num;
int zhishu[7000]={0};
int zend=0,flag;
int cs;
for(i=2;i<65536;i++)
{
flag=1;
for(j=2;j<i;j++)
{
if(i%j==0)
{
flag=0;
break;
}
}
if(flag)
{
zhishu[zend]=i;
zend++;
}
}
cs=1;
while(cin>>num&&num!=-1)
{
i=0;
printf("Case %d.\n",cs);
cs++;
while(num!=1)
{
temp=0;
while(num%zhishu[i]==0)
{
temp++;
num=num/zhishu[i];
}
if(temp!=0)
{
printf("%d %d ",zhishu[i],temp);
}
i++;
}
printf("\n\n");
}
return 0;
}
我知道了,看错题目了 展开
using namespace std;
int main()
{
int a,b,c;
long i,j,k;
int temp;
int num;
int zhishu[7000]={0};
int zend=0,flag;
int cs;
for(i=2;i<65536;i++)
{
flag=1;
for(j=2;j<i;j++)
{
if(i%j==0)
{
flag=0;
break;
}
}
if(flag)
{
zhishu[zend]=i;
zend++;
}
}
cs=1;
while(cin>>num&&num!=-1)
{
i=0;
printf("Case %d.\n",cs);
cs++;
while(num!=1)
{
temp=0;
while(num%zhishu[i]==0)
{
temp++;
num=num/zhishu[i];
}
if(temp!=0)
{
printf("%d %d ",zhishu[i],temp);
}
i++;
}
printf("\n\n");
}
return 0;
}
我知道了,看错题目了 展开
展开全部
#include <iostream>
using namespace std;
int main()
{
int n,c=1;
while(cin >> n)
{
if(n<0) break;
if(c!=1) cout << endl;
cout << "Case " << c << ".\n";
c++;
int temp=0,i=2;
while(i<=n)
{
if(n%i==0)
{
temp++;
n/=i;
}
else if(temp!=0)
{
cout << i << " " << temp << " ";
temp = 0;
i++;
}
else
{
temp = 0;
i++;
}
}
if(temp!=0)
{
cout << i << " " << temp << " ";
}
cout << endl;
}
}
行尾竟然有空格, 害我PE了.
using namespace std;
int main()
{
int n,c=1;
while(cin >> n)
{
if(n<0) break;
if(c!=1) cout << endl;
cout << "Case " << c << ".\n";
c++;
int temp=0,i=2;
while(i<=n)
{
if(n%i==0)
{
temp++;
n/=i;
}
else if(temp!=0)
{
cout << i << " " << temp << " ";
temp = 0;
i++;
}
else
{
temp = 0;
i++;
}
}
if(temp!=0)
{
cout << i << " " << temp << " ";
}
cout << endl;
}
}
行尾竟然有空格, 害我PE了.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询