#include <iostream> using namespace std; int main() { int n; cin >>n; cout <<n<<"*"<<n<<"*"<<n<<"="<<n*n*n<<"="; int m=n*n; if(m%2==0) { m=m-1; int x=m; for (int i=1;i<n/2;i++) { x-=2; cout <<x<<"+"; } cout <<x-2<<"+"; cout <<m<<"+"; m=m+2;cout <<m<<"+"; int y=m; for (int i=1;i<n/2;i++) { y+=2; cout <<y<<"+"; } cout <<y+2; } else { int s=m; for (int i=1;i<n/2;i++) { s-=2; cout <<s<<"+"; } cout <<s-2<<"+"; cout <<m<<"+"; int z=m; for (int i=1;i<n/2;i++) { z+=2; cout <<z<<"+"; } cout <<z+2; } cout <<'\b'; return 0; }
就是在那个输出的地方小的怎么绕到前面去~~~
相关分类