這是Herr Deng桑的教學blog,主要處理作業與班導事務,另外還有數位小品。
#include <iostream>#include <cstdlib>#include <string>#include <fstream>using namespace std;struct student{ int id; string name; int java; int math; int cpp; bool sex;};void print(student X, ostream& ff){ ff << X.id << "," ; ff << X.name << ","; ff << X.java << ","; ff << X.math << ","; ff << X.cpp << ","; ff << X.sex << ","; ff << "\n"; }void read(student&X, fstream& ff){ ff >> X.id; ff >> X.name; ff >> X.java; ff >> X.math; ff >> X.cpp; ff >> X.sex;}int main(){ student Y[10]; fstream ff, fout; ff.open("test.txt", ios::in); fout.open("ost.csv", ios::out); for (int i = 0; i < 10; i++) { read(Y[i], ff); print(Y[i], cout); print(Y[i],fout); } fout.close(); ff.close(); system("Pause"); return 0;}
#include <iostream>#include <cstdlib>#include <string>#include <fstream>using namespace std;struct student{int id;string name;int java;int math;int cpp;bool sex;};void print(student X, ostream& ff){ff << X.id << "," ;ff << X.name << ",";ff << X.java << ",";ff << X.math << ",";ff << X.cpp << ",";ff << X.sex << ",";ff << "\n";}void read(student&X, fstream& ff){ff >> X.id;ff >> X.name;ff >> X.java;ff >> X.math;ff >> X.cpp;ff >> X.sex;}int main(){student Y[10];fstream ff, fout;ff.open("test.txt", ios::in);fout.open("ost.csv", ios::out);for (int i = 0; i < 10; i++){read(Y[i], ff);print(Y[i], cout);print(Y[i],fout);}fout.close();ff.close();system("Pause");return 0;}
#include #include #include #include using namespace std;struct student{int id;string name;int java;int math;int cpp;bool sex;};void print(student X, ostream& ff){ff << X.id << "," ;ff << X.name << ",";ff << X.java << ",";ff << X.math << ",";ff << X.cpp << ",";ff << X.sex << ",";ff << "\n";}void read(student&X, fstream& ff){ff >> X.id;ff >> X.name;ff >> X.java;ff >> X.math;ff >> X.cpp;ff >> X.sex;}int main(){student Y[10];fstream ff, fout;ff.open("test.txt", ios::in);fout.open("ost.csv", ios::out);for (int i = 0; i < 10; i++){read(Y[i], ff);print(Y[i], cout);print(Y[i],fout);}fout.close();ff.close();system("Pause");return 0;}
HTML 編輯器
#include <iostream>
回覆刪除#include <cstdlib>
#include <string>
#include <fstream>
using namespace std;
struct student
{
int id;
string name;
int java;
int math;
int cpp;
bool sex;
};
void print(student X, ostream& ff)
{
ff << X.id << "," ;
ff << X.name << ",";
ff << X.java << ",";
ff << X.math << ",";
ff << X.cpp << ",";
ff << X.sex << ",";
ff << "\n";
}
void read(student&X, fstream& ff)
{
ff >> X.id;
ff >> X.name;
ff >> X.java;
ff >> X.math;
ff >> X.cpp;
ff >> X.sex;
}
int main()
{
student Y[10];
fstream ff, fout;
ff.open("test.txt", ios::in);
fout.open("ost.csv", ios::out);
for (int i = 0; i < 10; i++)
{
read(Y[i], ff);
print(Y[i], cout);
print(Y[i],fout);
}
fout.close();
ff.close();
system("Pause");
return 0;
}
#include <iostream>
回覆刪除#include <cstdlib>
#include <string>
#include <fstream>
using namespace std;
struct student
{
int id;
string name;
int java;
int math;
int cpp;
bool sex;
};
void print(student X, ostream& ff)
{
ff << X.id << "," ;
ff << X.name << ",";
ff << X.java << ",";
ff << X.math << ",";
ff << X.cpp << ",";
ff << X.sex << ",";
ff << "\n";
}
void read(student&X, fstream& ff)
{
ff >> X.id;
ff >> X.name;
ff >> X.java;
ff >> X.math;
ff >> X.cpp;
ff >> X.sex;
}
int main()
{
student Y[10];
fstream ff, fout;
ff.open("test.txt", ios::in);
fout.open("ost.csv", ios::out);
for (int i = 0; i < 10; i++)
{
read(Y[i], ff);
print(Y[i], cout);
print(Y[i],fout);
}
fout.close();
ff.close();
system("Pause");
return 0;
}
#include
回覆刪除#include
#include
#include
using namespace std;
struct student
{
int id;
string name;
int java;
int math;
int cpp;
bool sex;
};
void print(student X, ostream& ff)
{
ff << X.id << "," ;
ff << X.name << ",";
ff << X.java << ",";
ff << X.math << ",";
ff << X.cpp << ",";
ff << X.sex << ",";
ff << "\n";
}
void read(student&X, fstream& ff)
{
ff >> X.id;
ff >> X.name;
ff >> X.java;
ff >> X.math;
ff >> X.cpp;
ff >> X.sex;
}
int main()
{
student Y[10];
fstream ff, fout;
ff.open("test.txt", ios::in);
fout.open("ost.csv", ios::out);
for (int i = 0; i < 10; i++)
{
read(Y[i], ff);
print(Y[i], cout);
print(Y[i],fout);
}
fout.close();
ff.close();
system("Pause");
return 0;
}
#include
回覆刪除#include
#include
#include
using namespace std;
struct student
{
int id;
string name;
int java;
int math;
int cpp;
bool sex;
};
void print(student X, ostream& ff)
{
ff << X.id << "," ;
ff << X.name << ",";
ff << X.java << ",";
ff << X.math << ",";
ff << X.cpp << ",";
ff << X.sex << ",";
ff << "\n";
}
void read(student&X, fstream& ff)
{
ff >> X.id;
ff >> X.name;
ff >> X.java;
ff >> X.math;
ff >> X.cpp;
ff >> X.sex;
}
int main()
{
student Y[10];
fstream ff, fout;
ff.open("test.txt", ios::in);
fout.open("ost.csv", ios::out);
for (int i = 0; i < 10; i++)
{
read(Y[i], ff);
print(Y[i], cout);
print(Y[i],fout);
}
fout.close();
ff.close();
system("Pause");
return 0;
}
#include
回覆刪除#include
#include
#include
using namespace std;
struct student
{
int id;
string name;
int java;
int math;
int cpp;
bool sex;
};
void print(student X, ostream& ff)
{
ff << X.id << "," ;
ff << X.name << ",";
ff << X.java << ",";
ff << X.math << ",";
ff << X.cpp << ",";
ff << X.sex << ",";
ff << "\n";
}
void read(student&X, fstream& ff)
{
ff >> X.id;
ff >> X.name;
ff >> X.java;
ff >> X.math;
ff >> X.cpp;
ff >> X.sex;
}
int main()
{
student Y[10];
fstream ff, fout;
ff.open("test.txt", ios::in);
fout.open("ost.csv", ios::out);
for (int i = 0; i < 10; i++)
{
read(Y[i], ff);
print(Y[i], cout);
print(Y[i],fout);
}
fout.close();
ff.close();
system("Pause");
return 0;
}
#include
回覆刪除#include
#include
#include
using namespace std;
struct student
{
int id;
string name;
int java;
int math;
int cpp;
bool sex;
};
void print(student X, ostream& ff)
{
ff << X.id << "," ;
ff << X.name << ",";
ff << X.java << ",";
ff << X.math << ",";
ff << X.cpp << ",";
ff << X.sex << ",";
ff << "\n";
}
void read(student&X, fstream& ff)
{
ff >> X.id;
ff >> X.name;
ff >> X.java;
ff >> X.math;
ff >> X.cpp;
ff >> X.sex;
}
int main()
{
student Y[10];
fstream ff, fout;
ff.open("test.txt", ios::in);
fout.open("ost.csv", ios::out);
for (int i = 0; i < 10; i++)
{
read(Y[i], ff);
print(Y[i], cout);
print(Y[i],fout);
}
fout.close();
ff.close();
system("Pause");
return 0;
}
#include
回覆刪除#include
#include
#include
using namespace std;
struct student
{
int id;
string name;
int java;
int math;
int cpp;
bool sex;
};
void print(student X, ostream& ff)
{
ff << X.id << "," ;
ff << X.name << ",";
ff << X.java << ",";
ff << X.math << ",";
ff << X.cpp << ",";
ff << X.sex << ",";
ff << "\n";
}
void read(student&X, fstream& ff)
{
ff >> X.id;
ff >> X.name;
ff >> X.java;
ff >> X.math;
ff >> X.cpp;
ff >> X.sex;
}
int main()
{
student Y[10];
fstream ff, fout;
ff.open("test.txt", ios::in);
fout.open("ost.csv", ios::out);
for (int i = 0; i < 10; i++)
{
read(Y[i], ff);
print(Y[i], cout);
print(Y[i],fout);
}
fout.close();
ff.close();
system("Pause");
return 0;
}