C语言编程中的一些难题,谁来帮帮我?

来源:百度知道 编辑:UC知道 时间:2024/05/11 19:42:32
题 号 编程题第6题 文 件 名 T0706.CPP 截止日期 期末考试前提交有效
试题内容 编写程序以字符串为单位,以空格或标点符号(字符串中仅含','或'.'作为标点符号)作为分隔符,对字符串中所有单词进行倒排,之后把已处理的字符串(应不含标点符号)打印出来。例如:
原文为I am a student. I like study. 结果为study like I student a am I
数据描述 输入一行字符串,输出结果字符串。
输入格式 You He Me

I am a student, I like study.

输出格式 Me He You

study like I student a am I

题 号 编程题第16题 文 件 名 T0716.CPP 截止日期 期末考试前提交有效
试题内容 编写程序对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串中并打印出来。
条件:从字符串中间一分为二,左边部分按字符的ASCII值降序排序,右边部分按字符的ASCII值升序排序;排序后,左边部分与右边部分进行交换。如果原字符串长度为奇数,则最中间的字符不参加排序,字符仍放在原位置上。
数据描述 输入一行字符串,输出结果字符串。
输入格式 abcd9876

123456789

输出格式 6789dcba

678954321

第一题#include<iostream>
#include<string>
using namespace std;
int strlen(string);
void revers(string ,int);
void main()
{

cout<<"please input a string"<<endl;
string s1;
cin>>s1;
int t=strlen(s1);
cout<<"the length is "<<t<<endl;
revers(s1,t);

}
int strlen(string s)
{
int x;
x=s.end()-s.begin();
return x;
}
void revers(string s,int x)
{
for(int i=x-1;i>=0;i--)
cout<<s[i];
}

第一个题目:

#include<stdio.h>

typedef struct T
{
char word[50];

}T;

int main()
{
int count,length,i,j; char string[100],temp[50]; T t[100];

while(1)
{
gets(string);

count=0; length=0;

for(i=0;string[i]!='\0';i++)
{
if(string[i]!=' ' && st