血战换三张规则:C语言编程问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/26 05:49:15
由键盘任意输入一串字符,将其逆序存放后输出.例如,若输入的串为"abcdefg123456",则输出时为"654321gfedcba"

#include <stdio.h>
#include <conio.h>
int i=0;
char str[20] ;
void function()
{
char c, temp[30];
int j=0;
c=getch();
while(c!='\n')
{
temp[j++]=c;
c=getch();
}
temp[j]=0;
j=strlen(temp);
j--;
while(j>=0)
{
str[i++]=temp[j--];
}
puts(str);

}

int main()
{
function();
return 0;
}

这个好简单 我书上有 不过现在不在我这里 我编的出来 不过怕错了 等下我把书拿来 再发你给 记得和我联系