Advertisement
Guest User

C++ kursova zadacha

a guest
Apr 4th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6. const int N=2;
  7. string fam="Dimitrov";
  8. int sum=0;
  9. struct student
  10.           {
  11.                string name;
  12.             string familyName;
  13.             string facN;
  14.             string group;
  15.     };
  16.     typedef student Tmasstud[N+1];
  17.     Tmasstud masstud;
  18.  
  19. void instud(student &a)
  20.     {
  21.     cout<<"Name: ";
  22.     cin>>a.name;
  23.     cout<<"Family name: ";
  24.     cin>>a.familyName;
  25.     cout<<"F number: ";
  26.     cin>>a.facN;
  27.     cout<<"Group: ";
  28.     cin>>a.group;
  29.     }
  30.  
  31. void outstud(student a)
  32. {
  33.     cout<<a.name<<" ";
  34.     cout<<a.familyName<<" ";
  35.     cout<<a.facN<<" ";
  36.     cout<<a.group<<endl;
  37.     }
  38.  
  39. void input(Tmasstud a, int n)
  40. {
  41.     for(int i=1;i<=n;i++)
  42.     {
  43.         cout<<"Enter data for "<<i<<"student"<<endl;
  44.         instud(a[i]);
  45.     }
  46. }
  47.  
  48. void antetka()
  49. {cout<<"  Name"<<"   "<<" Family name"<<"   "<<" F number "<<"   "<<" Group"<<endl;}
  50.  
  51. void output(Tmasstud a, int n)
  52. {
  53.     antetka();
  54.     for(int i=1;i<=n;i++)
  55.         {
  56.             outstud(a[i]);
  57.         }
  58. }
  59. int strcom(student a)
  60. {
  61.   if(a.familyName.compare(fam)==0)
  62.             {
  63.                return 1;
  64.             }
  65.   else
  66.             {
  67.         return 0;
  68.     }
  69. }
  70.  
  71. void strcompare(Tmasstud a, int n)
  72. {
  73.     for(int i=0;i<n;i++)
  74.     {
  75.         sum+=strcom(a[i]);
  76.     }
  77.  
  78.     double perc=(sum/N)*100;
  79.     cout<<perc;
  80. }
  81. int main()
  82. {
  83.     input(masstud,N);
  84.     output(masstud,N);
  85.     strcompare(masstud,N);
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement