首页 > 其他 > 详细

实验七

时间:2018-06-20 12:35:22      阅读:220      评论:0      收藏:0      [点我收藏+]

1、

#include<iostream>
#include<string>
#include<fstream> 
#include<ctime>
const int N=83;
using namespace std;
    struct student{
        string num;
       string id,name,cl;
    };
    int main()
    {
        int i;
        student stu[N];
        ifstream in("list.txt");
        if(!in)
        {
            cout<<"fail to open"<<endl;
            return 1;
        }
        for(int i=0;i<=N;i++)
        {
            in>>stu[i].num>>stu[i].id>>stu[i].name>>stu[i].cl;
        }
        in.close();
        ofstream out("roll.txt");
        for(i=0;i<5;i++)
        {
            int a=rand()%N+1;
            srand(time(nullptr));
            cout<<stu[a].num<<" "<<stu[a].id<<" "<<stu[a].name<<" "<<stu[a].cl<<endl;
        out<<stu[a].num<<" "<<stu[a].id<<" "<<stu[a].name<<" "<<stu[a].cl<<endl;
            
        }
        out.close();
        return 0;
    }

我jio的我写的没什么问题,可就是运行不出来,可能会我电脑路径或者系统的问题,因为我发现我的list都不是.txt形式,就很气
明天去问问老师好了

实验七

原文:https://www.cnblogs.com/Nicholastwo/p/9202979.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!