南昌天虹商场活动:利用Mid函数和循环结合,将输入的字符串以反序显示.

来源:百度文库 编辑:中科新闻网 时间:2024/05/03 06:48:25
例如,输"abcde",显示"edcba"

#include "stdio.h"
main()
{char t,a[100];
int i,j;
gets(a);
for(i=0,j=strlen(a)-1;i<j;i++,j--)
{t=a[i];a[i]=a[j];a[j]=t;}
puts(a);
}

Dim a, b
a = "abcde"

b = StrReverse(a)

string a,b,c
int i,j
i=length(a)
for j=1 to i
c=mid(a,j,1)
b+=c
next
messagebox("结果",b)