自己学习过程中编写的,仅供参考,如有错误,欢迎评论区指正!
01
#include <stdio.h>
#define LEN 26
int main(void)
{
char ch[LEN];
char c;
for (int i = 0, c = 'a'; i < LEN; i++, c++)
{
ch[i] = c;
}
for (int i = 0; i < LEN; ++i)
{
printf("%c ", ch[i]);
}
return 0;
}
02
#include <stdio.h>
int main(void)
{
for (int i = 0; i < 5; ++i)
{
for (int j = 0; j <= i; ++j)
{
printf("$");
}
printf("\n");
}
return 0;
}
03
#include <stdio.h>
int main(void)
{
char ch;
for (int i = 0; i < 6; ++i)
{
ch = 'F';
for (int j = 0; j <= i; ++j)
{
printf("%c", ch--);
}
printf("\n");
}
return 0;
}
04
#include <stdio.h>
int main(void)
{
char ch;
for (int i = 0, ch = 'A'; i < 6; ++i)
{
for (int j = 0; j <= i; ++j)
{
printf("%c", ch++);
}
printf("\n");
}
return 0;
}
05
#include <stdio.h>
int main(void)
{
char ch, temp;
int len;
printf("请输入一个大写字母:");
scanf("%c", &ch);
len = ch - 'A'; //由Len确定打印行数,每行的空格数,打印字母数等
for (int i = 0; i < len + 1; ++i)