你把n=单独提到循环外面就行啊
printf("n="); for(i=0;i<n;i++) { }
直接使用字符串拼接啊 string sout="n="; for(i=0;i<n;i++) { sout=sout+.......... print() }