10.27 二进制打开文件漂亮
来源:互联网 发布:c语言的自定义函数 编辑:程序博客网 时间:2024/06/04 19:20
上代码//折磨一会子
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include<fstream>
#include <stack>
using namespace std;
int main() {
// int num;
ifstream fin("11", ios_base::binary);
//
// // map<int,vector<string> > m;
// string w;//最后输出
// while(fin>>num)
// {
//
// for(int i=0;i<num;i++)
// {
// stack<char>q;
// string s2;
// while(fin>>s2)
// {
// int l=s2.size();
// for(int j=0;j<l;j++)
// {
// q.push(s2[j]) ;
// }
// for(int j=0;j<l;j++)
// {
// w+=q.top();
// q.pop();
// }
// w+=" ";
//
// }
// w+='\n';
// }
// }
//
// cout << w << endl; // prints !!!Hello World!!!
int num;
char ch;
int l;
string w;
stack<char> q;
fin >> num;
fin.get(ch);
for(int j=0;j<num;j++)
{
fin.get(ch);
while (ch != '\n') {
if (ch != ' ') {
q.push(ch);
}
else
{
l=q.size();
for(int i=0;i<l;i++)
{
w+=q.top();
q.pop();
}
w+=' ';
}
fin.get(ch);
}
for(int i=0;i<l;i++)
{
w+=q.top();
q.pop();
}
w+=' ';
cout<<w;
cout<<endl;
w="";
}
cin >> num;
return 0;
}
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include<fstream>
#include <stack>
using namespace std;
int main() {
// int num;
ifstream fin("11", ios_base::binary);
//
// // map<int,vector<string> > m;
// string w;//最后输出
// while(fin>>num)
// {
//
// for(int i=0;i<num;i++)
// {
// stack<char>q;
// string s2;
// while(fin>>s2)
// {
// int l=s2.size();
// for(int j=0;j<l;j++)
// {
// q.push(s2[j]) ;
// }
// for(int j=0;j<l;j++)
// {
// w+=q.top();
// q.pop();
// }
// w+=" ";
//
// }
// w+='\n';
// }
// }
//
// cout << w << endl; // prints !!!Hello World!!!
int num;
char ch;
int l;
string w;
stack<char> q;
fin >> num;
fin.get(ch);
for(int j=0;j<num;j++)
{
fin.get(ch);
while (ch != '\n') {
if (ch != ' ') {
q.push(ch);
}
else
{
l=q.size();
for(int i=0;i<l;i++)
{
w+=q.top();
q.pop();
}
w+=' ';
}
fin.get(ch);
}
for(int i=0;i<l;i++)
{
w+=q.top();
q.pop();
}
w+=' ';
cout<<w;
cout<<endl;
w="";
}
cin >> num;
return 0;
}
- 10.27 二进制打开文件漂亮
- C二进制打开文件
- 二进制打开文件和文本打开文件的区别
- c++打开文件,以及搜索文件名二进制打开文件
- 以二进制方式打开文件并显示
- 二进制只读打开文件,并发送全过程
- [VBA] 以二进制方式打开文件
- 二进制和文本模式打开一个文件
- C语言文件打开和二进制打开方式的区别
- 文件打开的文本模式和二进制模式
- 文本与二进制方式打开文件的区别
- 文本与二进制方式打开文件的区别
- 文件打开的文本模式和二进制模式
- 文件打开的文本模式和二进制模式
- 文本与二进制方式打开文件的区别
- 文件打开的文本模式和二进制模式
- 文本与二进制方式打开文件的区别
- 文本与二进制方式打开文件的区别
- div+css总结—FF下div不设置高度背景颜色或外边框不能显示
- 远程控制1-现外网(固定ip)控制内网(无固定ip)
- 关于template的用法
- 模拟鼠标键盘
- vim入门,进阶与折腾
- 10.27 二进制打开文件漂亮
- 1.4 算法与算法分析
- hdu 2586 How far away ?<vector>
- 字符编码:ASCII、Unicode、UTF-8、UTF-16、UCS、BOM、Endian
- 毕业设计之路(4)——IP协议
- 机器学习10大经典算法
- 【开发总结】struts2整合spring
- 鸡与猪的争论
- 【枚举】连线游戏