Anupznk

4

Sep 2nd, 2019
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // NO 4
  3. #include<stdio.h>
  4. #include<string.h>
  5. typedef struct
  6. {
  7. int merit_pos;
  8. char name[50];
  9. char dept[20];
  10. }student_info;
  11.  
  12. int main()
  13. {
  14. int n;
  15. char buff;
  16. char dept_name[20];
  17. scanf("%d",&n);
  18. student_info std[n];
  19. for(int i=0;i<n;i++)
  20. {
  21. scanf("%d",&std[i].merit_pos);
  22. //scanf("%c",buff);
  23. scanf("%s",std[i].name);
  24. //scanf("%c",buff);
  25. scanf("%s",std[i].dept);
  26. // scanf("%c",buff);
  27. }
  28. scanf("%s",dept_name);
  29. // gets(dept_name);
  30. //scanf("%c",buff);
  31. // for(int i=0;i<n;i++)
  32. // {
  33. // if(strcmp(dept_name,std[i].dept==0))
  34. // break;
  35. // }
  36. for(int i=0;i<n;i++)
  37. {
  38. if(strcmp(dept_name,std[i].dept==0))
  39. {
  40. printf("Merit: %d Name: %s Dept: %s \n",std[i].merit_pos,std[i].name,std[i].dept);
  41. }
  42. }
  43. }
RAW Paste Data