C语言回滚(二)--循环打印
//1.用循环打印
/*
F
FE
FED
FEDC
FEDCB
FEDCBA
*/
#include <stdio.h>
#include<stdlib.h>
int main(){
for (int i = 0; i <6; i++)
{
char f = 'F';
//此时的i任然为0
for (int j = 0; j<=i; j++){
printf("%c",f );
f--;
}
printf("\n");
}
system("pause");
return 0;
}
//输入您要打印的最大的字母
例如输入E打印出
E
A
ABA
ABCBA
ABCDCBA
int main(){
//char ch;
int j, i, m, n;
char p;
scanf_s("%c", &p);
for (i = 0; i < 5; i++){
char ch = p-4;
for (j = 0; j <4 - i; j++)
printf(" ");
for (m = 0; m <= i; m++){
printf("%c", ch++);
}
ch = ch - 2;
for (n = 0; n < i; n++)
printf("%c", ch--);
printf("\n");
}
system("pause");
return 0;
}
ABCDEDCBA