输入不一个超过 80 个字符的字符串存于字符数组中,将数组中的字符串逆序后输出。
运行示例:
输入字符串: WindowsXP ↙
逆序后字符串为为:PXswodniW
【程序】
#include <stdio.h>
#include <string.h>
void main( )
{
char s[81],t;
int i,j,n;
printf(“
输入字符串:
”);
1 ; 【
A
、
scanf(“%d”,s) B
、
scanf(“%c”,s) C
、
scanf(“%f”,s) D
、
scanf(“%s”,s)
】
n=0;
while( 2 ) 【 A 、 n<81 B 、 n==81 C 、 s[n]!='\0' D 、 n!=0 】
n=n+1;
for(i=0, j=n-1; i<j; 3 ) 【 A 、 i++,j++ B 、 i++,j-- C 、 i--,j++ D 、 i--,j-- 】
{
t=s[i];
4 ; 【
A
、
s[i]=s[j] B
、
s[j]=s[i] C
、
t=s[j] D
、
t=s[i]
】
s[j]=t;
}
printf(" 逆序后字符串为为: ");
puts(s);
}