69,336
社区成员
发帖
与我相关
我的任务
分享
root@~ #cat 1.c
#include <stdio.h>
int main (void) {
char str[80],ch;
int i=0,j,len;
do {
ch=getchar();
str[i]=ch;
i++;
}while(ch!='\n');
str[i]='\0';
len=i;
j=i-1;
for(i=0;i<=len/2;i++,j--) {
ch=str[i];
str[i]=str[j];
str[j]=ch;
}
printf ("%s\n",str);
return 0;
}
#include <iostream>
#include <stack>
using namespace std;
int main(int argc, char** argv)
{
char input[5]; // 比需要输入的字符数多1
stack<char> stk;
cin >> input;
for(int i = 0; i < 4; i++)
{
stk.push(input[i]);
}
while (!stk.empty())
{
cout << stk.top();
stk.pop();
}
cout << endl;
return 0;
}