标签:io ar os sp for 文件 size c++ 应用
1、
// BlankTest.cpp : 定义控制台应用程序的入口点。
//题目:将一个文件中的一组整数排序后输出到另一个文件中
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
?
int _tmain(int argc, _TCHAR* argv[])
{
????ofstream out("11.txt",ios::out);
????for (int i = 0; i < 5; ++i)
????{
????????int te;
????????cin >> te;
????????out << te << " ";
????}
????out.close();
?
????ifstream infile("11.txt",ios::in);
????vector<int> data;
????while (!infile.eof())
????{
????????int temp;
????????infile >> temp;
????????data.push_back(temp);
????}
????for (int i = 0; i < data.size(); ++i)
????{
????????for(int j = i+1; j < data.size(); ++j)
????????{
????????????if(data[i] < data[j])
????????????{
????????????????int t = data[i];
????????????????data[i] = data[j];
????????????????data[j] = t;
????????????}
????????}
????}
?
????for (int i = 0; i < data.size(); ++i)
????{
????????cout << data[i] << " ";
????}
????return 0; //
}
2、
标签:io ar os sp for 文件 size c++ 应用
原文地址:http://www.cnblogs.com/zhuxuekui/p/4141198.html