請問要如何改才好?
#include <iostream>
using namespace std;
int main()
{
int n=0,h=0,m;
cin>>m;
int c[m],d[m]={0};
for(int i = 2 ; i<=m ;i++){
while(m%i == 0){
c[h] = i;
d[h] += 1;
m /= i;
}
if(d[h]>0){
h+=1;
}
}
if(d[0] == 1){
cout<<c[0];
}else{
cout<<c[0]<<'^'<<d[0];
}
for(int j = 1 ; j<h ; j++){
if(d[j]==1){
cout<<" * "<<c[j];
}else{
cout<<" * "<<c[j]<<'^'<<d[j];
}
}
return 0;
}