Created
January 7, 2022 14:18
-
-
Save msiahaan/1682f56c542ae0ec0d57e3f169f50857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <fstream> | |
using namespace std; | |
struct Siswa { | |
Siswa(){} | |
Siswa(string nama, string noHp) { | |
this->nama = nama; | |
this->noHp = noHp; | |
} | |
string nama; | |
string noHp; | |
}; | |
struct Guru { | |
Guru(string nama, vector <string> mapel) { | |
this->nama= nama; | |
this->mapel = mapel; | |
} | |
string nama; | |
vector <string> mapel; | |
}; | |
struct Kas { | |
Siswa siswa; | |
int total; | |
}; | |
void print_siswa(vector <Siswa> list) { | |
for (Siswa siswa : list) { | |
cout << siswa.nama << "\t" << siswa.noHp << endl; | |
} | |
} | |
void save_siswa(vector <Siswa> list) { | |
ofstream file{"list.txt", ios::out}; | |
for (Siswa siswa : list) { | |
file << siswa.nama << "," << siswa.noHp << endl; | |
} | |
} | |
vector <Siswa> init_siswa() { | |
Siswa A("Aldi Ananda Prasetya", "0813"); | |
Siswa B("Andre Sudarjo", "0856"); | |
Siswa C("Chairul Anwar Pane", "0882"); | |
Siswa D("Danda Rizky Febrian", "0838"); | |
Siswa E("M.Rifqi Nugraha", "0895"); | |
Siswa F("M.Rojak Muksid Putra", "0858"); | |
Siswa G("Muchtar Lutfi Saragih", "0895"); | |
Siswa H("Mustofa Kamal Putra Sanusi", "0895"); | |
Siswa I("Rendi", "0823"); | |
Siswa J("Rizki Apriyan", "0896"); | |
Siswa K("Rizky Ardiansyah", "0882"); | |
Siswa L("Rizky Ramadhan", "0857"); | |
Siswa M("Wahyudi Chandra", "0831"); | |
vector <Siswa> list {A, B, C, D, E, F, G, H, I, K, L, M}; | |
return list; | |
} | |
int main() { | |
vector <Siswa> daftar_siswa = init_siswa(); | |
cout << "Print Siswa" << endl; | |
print_siswa(daftar_siswa); | |
save_siswa(daftar_siswa); | |
Guru N("Linda Rusmawati,S.PD", {"Bahasa Inggris", "Bahasa Indonesia"}); | |
cout << endl << "Print Guru " << endl; | |
cout << N.nama << "\t" << "Mata pelajaran: "; | |
for (string pelajaran : N.mapel) { | |
cout << pelajaran << "\t" ; | |
} | |
cout << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment