zoukankan      html  css  js  c++  java
  • 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、

  • 相关阅读:
    layui使用iconfont
    MySQL&MyBatis 时间处理的配合
    Jira客户端
    同级div设置display:inline-block,父级div强制不换行
    Spring RestController 请求参数详解
    Mybatis映射文件
    Redis分布式锁
    Netty1
    Maven工程打成一个jar包
    Maven 工程读取resource下的文件
  • 原文地址:https://www.cnblogs.com/zhuxuekui/p/4141198.html
Copyright © 2011-2022 走看看