遞回實現字串逆序輸出

2020-08-10 11:47:02

遞回實現字串逆序輸出

#include<stdio.h>
void reverseSentence();

int main()
{
	printf("請輸入一個字串:");
	reverseSentence();
	return 0;
}

void reverseSentence()
{
	char c;
	scanf_s("%c", &c);
	if (c != '\n')
	{
		reverseSentence();
		printf("%c", c);
	}
}