hdu——1106排序(重定向)
来源:互联网 发布:tensorflow vgg 编辑:程序博客网 时间:2024/05/22 03:16
<h1 style="color: rgb(26, 92, 200);">排序</h1><strong><span style="color: green; font-family: Arial;">Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 48436 Accepted Submission(s): 13978</span></strong><div align="left" class="panel_title">Problem Description</div><div class="panel_content">输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整数就是由若干个‘0’组成的,这时这个整数就是0)。你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出。</div><div class="panel_bottom"> </div><div align="left" class="panel_title">Input</div><div class="panel_content">输入包含多组测试用例,每组输入数据只有一行数字(数字之间没有空格),这行数字的长度不大于1000。 输入数据保证:分割得到的非负整数不会大于100000000;输入数据不可能全由‘5’组成。</div><div class="panel_bottom"> </div><div align="left" class="panel_title">Output</div><div class="panel_content">对于每个测试用例,输出分割得到的整数排序的结果,相邻的两个整数之间用一个空格分开,每组输出占一行。</div><div class="panel_bottom"> </div><div align="left" class="panel_title">Sample Input</div><div class="panel_content"><pre><div style="font-family: Courier New,Courier,monospace;">0051231232050775</div>
Sample Output
0 77 12312320
Source
POJ
刚刚接触map 用法还不是很了解 stringstream用来重定向
用重定向把string类型转化为int型输入到容器中
最后记得把容器清空
#include<iostream>#include<algorithm>#include<cstdio>#include<string>#include<sstream>#include<vector>#include<cstdlib>using namespace std;int main() {string s;vector<int> num;while(cin >> s) {int buf;for(int i=0;i<s.length();i++)if(s[i]=='5')s[i]=' ';stringstream ss(s);while(ss >> buf)num.push_back(buf);//将ss复制给bufsort(num.begin(),num.end());for(vector<int>::iterator it=num.begin();it!=num.end();it++)if(it==num.begin()) cout << *it;elsecout << ' ' << *it; cout << endl;ss.str("");vector <int>().swap(num);//清空缓存}return 0;}
1 0
- hdu——1106排序(重定向)
- springMVC—重定向
- LinuxC/C++编程(6)—重定向、管道重定向
- [IO]——重定向
- freopen()——重定向标准输入输出流
- 文件处理——文件重定向(一)
- 文件处理——文件重定向(二)
- Linux笔记(14)——输入输出重定向
- 通过文件共享来学习I/O重定向(下)——I/O重定向
- 重定向Bash命令——time
- 重定向Bash命令——time
- linux常用命令——重定向
- Linux命令——重定向>和>>
- DRP——重定向与转发
- IO流——重定向流
- Shell——输入/输出重定向
- linux学习笔记—输出重定向
- Shell—输入/输出重定向
- 手写服务器httpserver_准备_http协议_http工具JAVA197-198
- uva 11584 Partitioning by Palindromes
- 深入浅出ClassLoader
- /* 判断一个对象是不是数组*/
- hadoop 2.7.2开发环境配置
- hdu——1106排序(重定向)
- 绘制模拟Android钟 ####时钟表盘
- Linux命令对应的全称解释
- python学习之常用的内置类(4):python中的XML
- Android 防内存泄露handler
- Leetcode #12 & #13 Integer to Roman & Roman to Integer 解题小节
- js惰性载入-性能-滚轮事件
- git创建项目并上传代码
- Spring AOP原理解释