总结:
1.这次代码写的很流畅而且没出错,原因就是自己之前就想了到底怎么写,下次一定要仔细想了在下手
代码:
#include<iostream>
#include<set>
#include<map>
using namespace std;
multiset<int> pp;
void xxx(long long m)
{
for (int i = 2; i*i <= m; i++)
{
if (m%i == 0){
pp.insert(i); m /= i; i = 1;
}
}
pp.insert(m);
}
map<int, int> stp;
int main()
{
long long m; int g = 1;
cin >> m;
xxx(m);
for (auto it = pp.begin(); it != pp.end(); it++)
{
stp[*it]++;
}
printf("%lld=", m); auto spy = stp.end(); spy--;
for (auto it = stp.begin(); it != stp.end();it++)
{
printf("%d",it->first);
if (it->second>1)printf("^%d",it->second);
if (it!=spy)printf("*");
}
return 0;
}