#include <iostream>
using namespace std;
int main()
{
int number,factor,times;
while(!cin.eof())
{
cin>>number;
if(number==1)
cout<<"1";
else
for(factor=2;factor<=number;factor++)
{
times=0;
while(number%factor==0)
{
number/=factor;
times++;
}
if(number==1)
{
if(times>1)
cout<<factor<<"^"<<times;
else if(times==1)
cout<<factor<<endl;
}
else
{
if(times>1)
cout<<factor<<"^"<<times<<" * ";
else if(times==1)
cout<<factor<<" * ";
}
}
}
return 0;
}
#include
using namespace std;
int main()
{
int number,factor,times;
while(!cin.eof())
{
cin>>number;
if(number==1)
cout<<"1";
else
for(factor=2;factor<=number;factor++)
{
times=0;
while(number%factor==0)
{
number/=factor;
times++;
}
if(number==1)
{
if(times>1)
cout<<factor<<"^"<<times;
else if(times==1)
cout<<factor<<endl;
}
else
{
if(times>1)
cout<<factor<<"^"<<times<<" * ";
else if(times==1)
cout<<factor<<" * ";
}
}
}
return 0;
}
粗體字不要這樣寫
改成while(cin>>number)好了