Advertisement
svetoslavhl

Untitled

May 27th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main(){
  7.  
  8.  
  9. int N;
  10.  
  11. do{
  12.  
  13. cout << "Vyvedete broia na uchasnicite:" << endl;
  14. cin >> N;
  15.  
  16. if(N <= 0 || N > 1000){
  17. cout << "Broiat uchastnici triabva da byde polojitelno chislo ne po goliamo ot 1000" << endl;
  18.  
  19. }
  20.  
  21.  
  22. }while(N <= 0 || N > 1000);
  23.  
  24.  
  25. struct uchastnici{
  26.  
  27. char imena[50];
  28. char grad[20];
  29. char uchilishte[30];
  30. int rezultat;
  31.  
  32.  
  33.  
  34.  
  35. }uchastnik[N] , uchastnikSOU[N] ,auxUchastnik[1];
  36.  
  37.  
  38. //VYVEJDAME UCHASTNICITE
  39.  
  40.  
  41. int i = 0;
  42. int opcia = 1;
  43. int totalRezultat;
  44.  
  45.  
  46. while(i < 1000 && opcia == 1){
  47.  
  48. cout << "Vyvedete dvete imena na uchastnika: " << endl;
  49. cin.getline(uchastnik[i].imena , 51 , '\n');
  50. cin.getline(uchastnik[i].imena , 51 , '\n');
  51.  
  52. cout << "Vyvedete grad na uchastnika: " << endl;
  53. cin.getline(uchastnik[i].grad , 21 , '\n');
  54.  
  55. cout << "Vyvedete uchilishte na uchastnika: " << endl;
  56. cin.getline(uchastnik[i].uchilishte , 31 , '\n');
  57.  
  58.  
  59.  
  60. do{
  61. cout << "Vyvedete rezultat na uchastnika:" << endl;
  62. cin >> uchastnik[i].rezultat;
  63.  
  64. if(uchastnik[i].rezultat < 0 ){
  65. cout << "Rezultata na uchastnika triabva da byde polojitelno chislo"<< endl;
  66.  
  67.  
  68. }
  69.  
  70.  
  71. }while(uchastnik[i].rezultat < 0);
  72.  
  73.  
  74. totalRezultat += uchastnik[i].rezultat;
  75.  
  76. i++;
  77.  
  78. cout << "Vyvedete 0 za krai ili 1 za prodyljavane na vyvejdane na uchastnici:" << endl;
  79. cin >> opcia;
  80.  
  81.  
  82. }
  83.  
  84. int sredenRezultat = totalRezultat/i;
  85. int j = 0;
  86.  
  87. // IZVLICHAME SAMO UCHASTNICITE KOITO SA OT SOU S REZULTAT PO VISOK OT SREDNIQ ZA OLIMPIADATA
  88.  
  89. for(int a = 0 ; a < i ; a++){
  90.  
  91. if(strstr(uchastnik[a].uchilishte , "SOU") != NULL && uchastnik[a].rezultat > sredenRezultat){
  92. uchastnikSOU[j] = uchastnik[a];
  93. j++;
  94.  
  95. }
  96.  
  97. }
  98.  
  99.  
  100. //OTPECHATVAME REZULTATA NA KONZOLATA
  101.  
  102. cout << sredenRezultat;
  103. for(int b = 0 ; b < j ; b++){
  104. cout << uchastnikSOU[b].imena << ", " << uchastnikSOU[b].grad << ", " << uchastnikSOU[b].uchilishte << ", " << uchastnikSOU[b].rezultat << " tochki"<< endl;
  105.  
  106.  
  107. }
  108.  
  109.  
  110. system("pause");
  111.  
  112.  
  113.  
  114.  
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement