这个练习昨天就在做了,但是没有成功,因为要用大量的for循环,用了两层以上的循环我就开始晕。然后我想既然要那样输出,很自然想到用二维数组结果我也没有实现。于是我就去上网看了别人的代码,别人太会找规律了,A出现的地方左右递减就可以了o(╥﹏╥)o。
要多找规律。
下面是代码
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main() {
int w='A';
int n,m;
scanf("%d %d",&n,&m);
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
printf("%c",w+abs(i-j));
}
printf("\n");
}
return 0;
}