问答题

请编写函数fun(),对长度为7个字符的字符串,除首、尾字符外,将其余5个字符按ASCII码值降序排列。
例如:原来的字符串为CEAedca,则排序后输出为CedcEAa。
注意:部分源程序已存在文件test22_2.cpp中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
文件test22_2.cpp的内容如下:
#include <iostream.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
void int fun(char *s, int num)


void main ( )

char s[10];
printf ("输入7个字符的字符串:");
gets(s);
fun(s,7);
cout<<s;

【参考答案】

int fun(char*s,int num)
{char t;
int i,j;
fo......

(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)