SHARE
TWEET

Untitled

a guest Dec 8th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // PROBLEM C
  2. #include<stdio.h>
  3.  
  4. struct lecturerData{
  5.   char lcode[31];
  6.   char lname[31];
  7.   char lsex[10];
  8.   int std;
  9. }lecturer[101];
  10.  
  11. struct studentData{
  12.   char scode[31];
  13.   char sname[31];
  14.   char ssex[10];
  15.   char dad[31];
  16.   char mom[31];
  17.   int sib;
  18. }student[101][101];
  19.  
  20. void printData(int x){
  21.  
  22.   printf("Kode Dosen: %s\n", lecturer[x].lcode);
  23.   printf("Nama Dosen: %s\n", lecturer[x].lname);
  24.   printf("Gender Dosen: %s\n", lecturer[x].lsex);
  25.   printf("Jumlah Mahasiswa: %d\n", lecturer[x].std);
  26.  
  27.   for(int s=1; s<=lecturer[x].std; s++){
  28.     printf("Kode Mahasiswa: %s\n", student[x][s].scode);
  29.     printf("Nama Mahasiswa: %s\n", student[x][s].sname);
  30.     printf("Gender Mahasiswa: %s\n", student[x][s].ssex);
  31.     printf("Nama Ayah: %s\n", student[x][s].dad);
  32.     printf("Nama Ibu: %s\n", student[x][s].mom);
  33.     printf("Jumlah Saudara Kandung: %d\n", student[x][s].sib);
  34.   }
  35. }
  36.  
  37.  
  38. int main(){
  39.  
  40.   int L;
  41.   scanf("%d", &L); getchar();
  42.  
  43.   for(int l=1; l<=L; l++){
  44.     scanf("%s", &lecturer[l].lcode); getchar();
  45.     scanf("%[^\n]", &lecturer[l].lname); getchar();
  46.     scanf("%[^\n]", &lecturer[l].lsex); getchar();
  47.     scanf("%d", &lecturer[l].std); getchar();
  48.  
  49.     for(int s=1; s<=lecturer[l].std; s++){
  50.       scanf("%s", &student[l][s].scode); getchar();
  51.       scanf("%[^\n]", &student[l][s].sname); getchar();
  52.       scanf("%[^\n]", &student[l][s].ssex); getchar();
  53.       scanf("%[^\n]", &student[l][s].dad); getchar();
  54.       scanf("%[^\n]", &student[l][s].mom); getchar();
  55.       scanf("%d", &student[l][s].sib); getchar();
  56.     }
  57.   }
  58.  
  59.   int x;
  60.   scanf("%d", &x);
  61.  
  62.   printData(x);
  63.  
  64.   return 0;
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top