倒顺字母字符串-hebust
根据输入n的大小(1=<n<=26),输出相对应的倒顺字符串。
输入格式:
输入格式:5
输出格式:
a b c d e d c b a
输入样例:
在这里给出一组输入。例如:
5
输出样例:
在这里给出相应的输出。例如:
a b c d e d c b a
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n=0,i=0,j=0;
char a=97;
scanf("%d",&n);
j=n-2;
if(n==1){
printf("a");
goto loop;
}
for(;i<n;i++)printf("%c ",a+i);
for(;j>=0;j--){
if(j==0){
printf("%c",a+j);
break;
}
printf("%c ",a+j);
}
loop:
return 0;
}