string数组按照字母排序
来源:互联网 发布:python 函数定义和调用 编辑:程序博客网 时间:2024/05/22 12:10
#include<iostream>#include<fstream>#include <algorithm>#include<string>using namespace std;class Words{public:// 获取输入字符串到文件中void ppsssWords(){ofstream outfile("字符处理.txt");gets_s(m_strWords);outfile << m_strWords;outfile.close();}// 获取文件中的单词,输出到数组str中,并进行排序void paxu(){ifstream infile("字符处理.txt");string str[10], tame;int count_str = 0;infile >> str[count_str];while (!infile.eof()){count_str++;infile >> str[count_str];}for (int i = 0; i <= count_str; i++){cout << str[i] << " ";}cout << endl;for (int j = 0; j <= count_str - 1; j++){for (int i = 0; i <= count_str - j - 1; i++){if (str[i][0] > str[i + 1][0]){tame = str[i];str[i] = str[i + 1];str[i + 1] = tame;//交换相邻的}}}for (int i = 0; i <= count_str; i++){cout << str[i] << " ";}cout << endl;}private:char m_strWords[100];int t;};int main(){Words word;word.ppsssWords();word.paxu();}
阅读全文
0 0
- string数组按照字母排序
- 字符串数组按照字母排序
- Android数组列表按照字母排序
- iOS 数组中的string 按照字典排序
- 汉字按照字母排序
- 微软面试题-字符串数组按照字母排序
- 面试题题排序,字符串数组按照字母排序,不区分大小写比较
- 按照XX数组排序
- dedecms文章标题按照字母排序
- 微软Java面试题-按照字母排序
- android 按照字母的顺序排序
- 按照首先字母进行元素排序
- 实现按照字母分类分组排序
- 给Map排序---按照key的字母
- 使用Java统计字母并且按照字母的次数排序
- 数组按照对象属性排序
- 数组按照某一字段排序
- String demos[]={"hello","chenhj","test","中国"} 对数组的字符按照数据字典排序
- 自动化测试用例操作
- SOAP及SoapObject的解析
- Oracle scott 用户解锁
- dfgh
- 文件缓存
- string数组按照字母排序
- svn 使用详解
- 文章标题
- Unity Steam_VR VRTK开发插件自带案例详解(一)
- Java可视操作界面例子
- 开始我的python学习之路
- GIT使用
- getResource()和getSystemResource()分析
- 无限轮播