字符串倒置

题目

将给定的字符串进行反序存放并输出

输入

一行字符串

输出

将输入的字符串进行反序输出,并单独占一行

样例输入

abcd

样例输出

dcba

代码块

#include <stdio.h>
#include <string.h>
int main(){
	char str[10];
	char temp[10] = {};
	scanf("%s",str);
	int line =strlen(str); 
	for(int i =0 ;i <line ;i++){
		temp[i] = str[line-1-i];
	} 
	puts(temp);
	return 0;
} 

输出结果

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_156874635/article/details/83187593