Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
#include <string>
#include <vector>
struct MataKuliah {
std::string kode;
std::string nama;
int sks;
MataKuliah(const std::string& _kode, const std::string& _nama, int _sks)
: kode(_kode), nama(_nama), sks(_sks) {}
};
struct Mahasiswa {
int nomor;
std::string nama;
std::vector<MataKuliah> daftarMataKuliah;
Mahasiswa(int _nomor, const std::string& _nama)
: nomor(_nomor), nama(_nama) {}
};
int main() {
std::vector<Mahasiswa> daftarMahasiswa;
while (true) {
std::cout << "Masukkan nomor mahasiswa (atau -1 untuk keluar): ";
int nomor;
std::cin >> nomor;
if (nomor == -1) {
break;
}
std::cout << "Masukkan nama mahasiswa: ";
std::string nama;
std::cin.ignore();
std::getline(std::cin, nama);
Mahasiswa mahasiswa(nomor, nama);
while (true) {
std::cout << "Masukkan kode mata kuliah (atau 'selesai' untuk selesai): ";
std::string kode;
std::cin >> kode;
if (kode == "selesai") {
break;
}
std::cout << "Masukkan nama mata kuliah: ";
std::string namaMk;
std::cin.ignore();
std::getline(std::cin, namaMk);
std::cout << "Masukkan jumlah SKS: ";
int sks;
std::cin >> sks;
MataKuliah mk(kode, namaMk, sks);
mahasiswa.daftarMataKuliah.push_back(mk);
}
daftarMahasiswa.push_back(mahasiswa);
}
// Tampilkan hasil
for (const Mahasiswa& mahasiswa : daftarMahasiswa) {
std::cout << "Nomor Mahasiswa: " << mahasiswa.nomor << ", Nama Mahasiswa: " << mahasiswa.nama << std::endl;
std::cout << "Daftar Mata Kuliah:" << std::endl;
for (const MataKuliah& mk : mahasiswa.daftarMataKuliah) {
std::cout << "Kode: " << mk.kode << ", Nama: " << mk.nama << ", SKS: " << mk.sks << std::endl;
}
std::cout << std::endl;
}
return 0;
}
![]() |
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team