一个文本输入的问题。。 float
时间:2011-12-27
来源:互联网
a b 22.2
; A7 y) L, c7 m8 Y" @a b 33.2
8 J' g1 P0 q# b: {5 B: \* [a b 33.2
; S' F# V* f3 f8 e2 u5 ga b 22.3
u5 I; l4 A* l' N4 w( L这是文本内容
这个代码碰到非float型的内容后就会停止输入内容到list里面, 这个怎么解??
; A7 y) L, c7 m8 Y" @a b 33.2
8 J' g1 P0 q# b: {5 B: \* [a b 33.2
; S' F# V* f3 f8 e2 u5 ga b 22.3
u5 I; l4 A* l' N4 w( L这是文本内容
复制内容到剪贴板
#include <iostream>
#include <list>
#include <fstream>
#include <string>
#include<map>
using namespace std;
int main()
{
ifstream read("123.txt");
float word;
list<float>mylist;
while(read)
{
read>>word;
mylist.push_back(word);
}
list<float>::iterator iter;
for ( iter=mylist.begin() ; iter != mylist.end(); iter++ )
cout << *iter<< endl;
system("pause");
}
这是代码。。 $ ?) T0 l' Z e+ l& u代码:
#include <iostream>
#include <list>
#include <fstream>
#include <string>
#include<map>
using namespace std;
int main()
{
ifstream read("123.txt");
float word;
list<float>mylist;
while(read)
{
read>>word;
mylist.push_back(word);
}
list<float>::iterator iter;
for ( iter=mylist.begin() ; iter != mylist.end(); iter++ )
cout << *iter<< endl;
system("pause");
}
这个代码碰到非float型的内容后就会停止输入内容到list里面, 这个怎么解??
作者: alleni 发布时间: 2011-12-27
复制内容到剪贴板
#include<map>
using namespace std;
int main()
{
ifstream read("123.txt");
float word;
list<float>mylist;
read.seekg(4,fstream::cur);
read>>word;
mylist.push_back(word);
while(1)
{
read.seekg(5,fstream::cur);
read>>word;
if(!read)break;
mylist.push_back(word);
}
list<float>::iterator iter;
for ( iter=mylist.begin() ; iter != mylist.end(); iter++ )
cout << *iter<< endl;
system("pause");
}
代码:
#include <string>#include<map>
using namespace std;
int main()
{
ifstream read("123.txt");
float word;
list<float>mylist;
read.seekg(4,fstream::cur);
read>>word;
mylist.push_back(word);
while(1)
{
read.seekg(5,fstream::cur);
read>>word;
if(!read)break;
mylist.push_back(word);
}
list<float>::iterator iter;
for ( iter=mylist.begin() ; iter != mylist.end(); iter++ )
cout << *iter<< endl;
system("pause");
}
作者: 月夜幻影 发布时间: 2011-12-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28