题目内容:
从键盘输入一个句子(假设字符数小于100个),句子中的单词之间用空格分隔,句子必须以一个标点符号作为结尾,句子开头和末尾标点符号前均没有空格,以回车表示输入结束,请编程颠倒句中的单词顺序并输出。
函数原型:int Inverse(char str1[], char str2[][N])
将
程序运行结果示例1:
Input a sentence:you can cage a swallow can’t you?↙
you can’t swallow a cage can you?
程序运行结果示例2:
Input a string:you are my sunshine!↙
sunshine my are you!
程序运行结果示例3:
Input a sentence:I love you!↙
you love I!
输入提示信息:“Input a sentence:”
输入格式: 用gets()函数
输出格式:
每个单词的输出格式:"%s " (注意: %s后面有一个空格)
最后一个单词和标点符号的输出格式:"%s%c\n"
方法1(数组)
#include<stdio.h>
#include<string.h>
#define N 100
int Inverse(char str1[], char str2[][N]);
int main()
{
char str1[N],str2[N][N],a;
int i=0,j;
gets(str1);
a=str1[strlen(str1)-1]; //将字符串在结尾处的标点符号保存起来。
str1[strlen(str1)-<