求C程序代码

2025-04-17 08:49:29
推荐回答(2个)
回答1:

#include 
void main()
{
char s[1000] = {0};
char *p = &s[999];
char c;
while (1)
{
scanf("%c", &c);
if (c == '=')break;
p--;
*p = c;

}
printf("%s", p);

scanf("%s", s);
}

回答2:

#include

int main()
{
    char buf[10000];
    char *p = buf, *q, tmp;
    int i, bufCount = 0;
    while(1){
        tmp = getche();
        if(tmp == '=')
            break;
        buf[bufCount++] = tmp;
    }

    q = p + bufCount - 1;

    while(p < q){
        tmp = *p;
        *p = *q;
        *q = tmp;

        p++;
        q--;
    }
    printf("\n");
    for(i = 0; i < bufCount; i++)
        printf("%c", buf[i]);

    system("pause");
    return 0;