空心菱形问题??
由键盘输入空心菱形的行高*
* * *
* * * *
* * * *
* * * *
* * * *
* * * *
* * *
*
能解释下吗
#include "stdafx.h" #include <math.h> #include <stdio.h> int main(int argc, char* argv[]) { int len; printf("please input is Diamond number of rows:"); scanf("%d", &len); for (int i = -len; i <= len; i++) { for (int j = -len; j <= len; j++) { if (abs(i)+abs(j) == len-1) { printf("*"); } else { printf(" "); } } printf("\n"); } return 0; }