#include <stdio.h> #include <math.h> #include <stdlib.h> void func(int m) { int* sum= (int*)malloc(sizeof(int*)*m); int n = pow(m,3); int num = m*(m-1)+1; int count = 0; for(count = 0;count<=m-1;count++) { sum[count]=num; num+=2; } for(count = 0;count<=m-1;count++) { if(count==m-1) { printf("%d",sum[count]); } else { printf("%d+",sum[count]); } } } int main() { int m; while(~scanf("%d",&m)) { func(m); printf("\n"); } }没啥好讲的,数学关系推导出加和元素的初始值为 (m*(m-1)+1),后面就信手拈来了