编写c语言程序,要求用户输入一个字符串,程序将字符串字母反序输出.即如果输入为abcd,则输出为dcba.

如题所述

第1个回答  2012-12-11
#include<stdio.h>
#include<string.h>
int main()
{
char str[20],c;
int i,n;
printf("str=");
gets(str);
n=strlen(str);
for(i=0;i<n/2;i++)
{
c=str[i];
str[i]=str[n-i-1];
str[n-i-1]=c;
}
puts(str);
return 0;
}本回答被提问者采纳
第2个回答  2018-10-23
#include <stdio.h>
void mian(){
char c='d';
while(c>='a'){
printf("%c\n",c);
c--;
}
}
第3个回答  2017-08-15
#include <stdio.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
char i=0,j,a[200],b[200];
scanf("%s",&a);
while(a[i] != '\0')
     {b[i] = a[i]; i++;}  
    for (j = 0; j < i; j++) a[j] = b[i - 1 - j];  
    b[j] = a[i];
    printf("%s\n",a);
return 0;
}

相似回答