c语言 输出由26个字母组成的26行等腰三角形
时间: 2023-12-14 17:03:32 浏览: 102
```
#include <stdio.h>
int main() {
int i, j, k;
for (i = 1; i <= 26; i++) {
for (j = 1; j <= 26 - i; j++) {
printf(" ");
}
for (k = 1; k <= i; k++) {
printf("%c ", 'A' + k - 1);
}
for (k = i - 1; k >= 1; k--) {
printf("%c ", 'A' + k - 1);
}
printf("\n");
}
return 0;
}
```
输出结果:
```
A
A B A
A B C B A
A B C D C B A
A B C D E D C B A
A B C D E F E D C B A
A B C D E F G F E D C B A
A B C D E F G H G F E D C B A
A B C D E F G H I H G F E D C B A
A B C D E F G H I J I H G F E D C B A
A B C D E F G H I J K J I H G F E D C B A
A B C D E F G H I J K L K J I H G F E D C B A
A B C D E F G H I J K L M L K J I H G F E D C B A
A B C D E F G H I J K L M N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R S R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R S T S R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R S T U T S R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R S T U V U T S R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R S T U V W V U T S R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R S T U V W X W V U T S R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R S T U V W X Y X W V U T S R Q P O N M L K J I H G F E D C B A
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
```
阅读全文