Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5.  
  6. struct movie {
  7. char title[100];
  8. char dname[100];
  9. char nf[100];
  10. char nm[100];
  11. int date;
  12. int price;
  13. };
  14.  
  15.  
  16. int main()
  17. {
  18. struct movie mv[200];
  19. float max = mv[0].price, tot=0;
  20. int maxi = 0, n=3, count = 0;
  21. for (int i = 0; i < n;i++){
  22. gets(mv[i].title);
  23. gets(mv[i].dname);
  24. gets(mv[i].nf);
  25. gets(mv[i].nm);
  26. scanf("%d", &mv[i].date);
  27. scanf("%d", &mv[i].price);
  28. }
  29.  
  30. for (int i = 0;i<n;i++) {
  31. if (mv[i].price > max){
  32. max = mv[i].price;
  33. maxi = i;
  34. }
  35. if (strcpy(mv[i].nf, "Meg Ryan") == 0) {
  36. tot += mv[i].price;
  37. count++;
  38. }
  39. }
  40. float avg = tot/count;
  41.  
  42. printf("%s %f", mv[maxi].dname, avg);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement