练习7-11 字符串逆序 (15 point(s))

练习7-11 字符串逆序 (15 point(s))

输入一个字符串,对该字符串进行逆序,输出逆序后的字符串。

输入格式:

输入在一行中给出一个不超过80个字符长度的、以回车结束的非空字符串。

输出格式:

在一行中输出逆序后的字符串。

输入样例:

Hello World!

输出样例:

!dlroW olleH
#include<stdio.h>#include<stdio.h>
int main(){
  int j,i,count;
  char ch,str[80],a[80];
  ch=getchar();
  for(i=0;ch!='\n';i++){
    str[i]=ch;
    count++;
    ch=getchar();
    
  }
 for(i=0,j=count-1;i<count;i++,j--)
      a[j]=str[i];
      for(i=0;i<count;i++)
      printf("%c",a[i]);
      return 0;
      
 
  
} 

猜你喜欢

转载自blog.csdn.net/qq_42057358/article/details/84036134
今日推荐