I/O compile
来源:互联网 发布:java pkcs10 公钥 编辑:程序博客网 时间:2024/06/15 10:25
write-file
//#include "stdafx.h"#include<iostream>#include <string>#include<stdio.h>#include<cstring>#include<array>#include<fstream>using namespace std;//ostream define cout ,display on the screen//fstream define fout ,display in the fileint main(){ ofstream fout; fout.open("first.txt"); string automobile; int year; double sprice, dprice; cout << "enter the make and model of automo\t\n"; cin >> automobile; cout << "\n\tenter the mobile year\n\t"; cin >> year; cout << "enter the price\n"; cin >> sprice; dprice = 0.879*sprice; cout << fixed;//yong yibande fangshishuchufudianshu erbushikexuejishufa cout.precision(2); cout.setf(ios_base::showpoint); cout << "make and model\t" << automobile << endl; cout << "year\t" << year << endl; cout << "pro price\t" << sprice << endl; cout << "the price\t" << dprice << endl; fout << fixed;//yong yibande fangshishufhufudianshu erbushikexuejishufa fout.precision(2); fout.setf(ios_base::showpoint); fout << "make and model\t" << automobile << endl; fout << "year\t" << year << endl; fout << "pro prife\t" << sprice << endl; fout << "the prife\t" << dprice << endl; fout.close(); return 0;}
read-file
int main(){ //first one-check number ifstream fin; fin.open("first.txt"); if (!fin.is_open()) { cout << "fuckyou\t\n"; exit(EXIT_FAILURE); } double n; int count = 0; while (fin>>n) { count++; cout << n<<endl; fin >> n; } if (fin.eof())//最后一个fin读到 EOF ,eof()return ture cout << "reach end\n"; else if (fin.fail())//类型不匹配 cout << "data dismatch\n"; else cout << "unknown reason\n"; cout << count; //second one-check word return 0;}
my-own findword
int main(){ //first one-check number ifstream fin; fin.open("first.txt"); if (!fin.is_open()) { cout << "fuckyou\t\n"; exit(EXIT_FAILURE); } char n; int count = 0; while (fin.get(n)) { count++; cout << n; fin.get(n); }; if (fin.eof())//最后一个fin读到 EOF ,eof()return ture cout << "reach end\n"; else if (fin.fail())//类型不匹配 cout << "data dismatch\n"; else cout << "unknown reason\n"; cout << count; //second one-check word return 0;}
shit,the result is wrong
but i cannot figure it out right now!!!!!
阅读全文
0 0
- I/O compile
- I/O
- I/O
- I/O
- I/O
- I/O
- I/O
- I/O
- I/O
- I/O
- i/o
- I/O
- I/O
- I/O
- I/O
- I/O
- I/O
- I/O
- scala(6)-----运算符
- Spark在Windows下的环境搭建
- Docker容器与外部网络的链接-与外部网络链接
- bzoj1461: 字符串的匹配
- TensorFlow练习: 根据大脸判断性别和年龄
- I/O compile
- 关于在web中的数据传递
- springmvc-web.xml无法映射的问题解惑
- 19th 【最短路 floyd】租用游艇
- Go语言学习之signal(二)
- java中的native方法
- shell基础
- POJ 2602 Superlong sums G++
- 获取网易云音乐封面图片