C语言字符排序
該博文為原創(chuàng)文章,未經(jīng)博主同意不得轉(zhuǎn)載,如同意轉(zhuǎn)載請注明博文出處
本文章博客地址:https://cplusplus.blog.csdn.net/article/details/105164067
C語言字符排序
- 如題
- 話不多說了,直接上代碼
如題
函數(shù) ReadDat()實(shí)現(xiàn)從文件 in.dat 中讀取 20 行數(shù)據(jù)存放到字符串?dāng)?shù)組 xx 中(每行字符串長 度均小于 80)。
請編制函數(shù) jsSort(),其函數(shù)的功能是:以行為單位對字符串變量的下標(biāo)為 奇數(shù)的字符按其 ASCII 值從小到大的順序進(jìn)行排序,排序后的結(jié)果仍按行重新存入字符串 數(shù)組 xx 中,后調(diào)用函數(shù) WriteDat()把結(jié)果 xx 輸出到文件 out.dat 中。
例如:位置 0 1 2 3 4 5 6 7
源字符串 a b c d e f g h
則處理后字符串 a h c f e d g b
部分源程序存在文件 prog1.c 中。
請勿改動主函數(shù) main()、讀數(shù)據(jù)函數(shù) ReadDat()和輸出數(shù)據(jù)函數(shù) WriteDat()的內(nèi)容。
話不多說了,直接上代碼
#include <stdio.h>
#include <string.h>
#include <conio.h>
char xx[20][80];
void jsSort()
{int i,j,k,strl;
char ch; for(i=0;i<20;i++)</
總結(jié)
- 上一篇: 鱼肚家常做法?
- 下一篇: C语言SIX/NINE问题