main(){ char str[4]; for(;~scanf("%s",&str)&&printf("%c%c%c%c\n",str[3],str[2],str[1],str[0]);); }
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner in=new Scanner(System.in); while(in.hasNext()){//循环输入 String str=in.nextLine();//字符输入 char array[]=str.toCharArray();//字符串转换成数组 for(int i=array.length-1;i>=0;i--){//倒序输出 System.out.print(array[i]); } System.out.println(); } in.close(); } } //本题也可以尝试用栈做
void print(char *str,int n); int main(void) { int i; char str[10]; while(scanf("%s",&str)!=EOF) { //for(i=3;i>=0;i--) // printf("%c",str[i]); print(str,3); printf("\n"); } return 0; } void print(char *str,int n) { if(n>=0) { printf("%c",*(str+n)); print(str,n-1); } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Six{ public static void main(String[] args) { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); String str = ""; StringBuffer sb = new StringBuffer(); try { while ((str=bufferedReader.readLine())!=null){ System.out.println(sb.append(str).reverse().toString()); sb.replace(0,sb.length(),""); } } catch (IOException e) { e.printStackTrace(); } } }