大佬可以帮我找一下错误原因吗,谢谢
#include<stdio.h>
int main() {
int N,a,b;
scanf("%d", &N);
while (N-- > 0) {
scanf("%d%d", &a, &b);
char image[40][40] = {' '};
for (int i = 0; i < a; i++) {
image[i][i] = 'X';
image[i][a - 1 - i] = 'X';
}
for (int j = 1; j <= b; j++) {
if (j == 1) {
for (int i = 0; i < a; i++) {
for (int k = 0; k < a; k++)
printf("%c", image[i][k]);
printf("\n");
}
}
else {
for (int i = 1; i < a; i++) {
for (int k = 0; k < a; k++)
printf("%c", image[i][k]);
printf("\n");
}
}
}
printf("\n");
}
}
2020-02-14 12:39:49
酒笙清栀 2020-02-14 23:09:44 |
#include<stdio.h> int main() { int N,a,b; scanf("%d", &N); while (N--) { scanf("%d%d", &a, &b); char image[40][40]={' '}; for (int i = 0; i < a; i++) { for(int k=0;k<a;k++) { if(i==k||i+k==a-1) image[i][k] = 'X'; else image[i][k] = ' '; } } for (int j = 1; j <= b; j++) { if (j == 1) { for (int i = 0; i < a; i++) { for (int k = 0; k < a; k++) printf("%c", image[i][k]); printf(" "); } } else { for (int i = 1; i < a; i++) { for (int k = 0; k < a; k++) printf("%c", image[i][k]); printf(" "); } } } printf(" "); } }
酒笙清栀 2020-02-14 23:10:47 |
太难了 我试了好多次 这回对了。
citylove 2020-07-18 15:43:29 |
@w0309 请问是哪里出错了,我也经常这样结果试着都对,但是就是在这编译不过