Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main(){
- int N;
- do{
- cout << "Vyvedete broia na uchasnicite:" << endl;
- cin >> N;
- if(N <= 0 || N > 1000){
- cout << "Broiat uchastnici triabva da byde polojitelno chislo ne po goliamo ot 1000" << endl;
- }
- }while(N <= 0 || N > 1000);
- struct uchastnici{
- char imena[50];
- char grad[20];
- char uchilishte[30];
- int rezultat;
- }uchastnik[N] , uchastnikSOU[N] ,auxUchastnik[1];
- //VYVEJDAME UCHASTNICITE
- int i = 0;
- int opcia = 1;
- int totalRezultat;
- while(i < 1000 && opcia == 1){
- cout << "Vyvedete dvete imena na uchastnika: " << endl;
- cin.getline(uchastnik[i].imena , 51 , '\n');
- cin.getline(uchastnik[i].imena , 51 , '\n');
- cout << "Vyvedete grad na uchastnika: " << endl;
- cin.getline(uchastnik[i].grad , 21 , '\n');
- cout << "Vyvedete uchilishte na uchastnika: " << endl;
- cin.getline(uchastnik[i].uchilishte , 31 , '\n');
- do{
- cout << "Vyvedete rezultat na uchastnika:" << endl;
- cin >> uchastnik[i].rezultat;
- if(uchastnik[i].rezultat < 0 ){
- cout << "Rezultata na uchastnika triabva da byde polojitelno chislo"<< endl;
- }
- }while(uchastnik[i].rezultat < 0);
- totalRezultat += uchastnik[i].rezultat;
- i++;
- cout << "Vyvedete 0 za krai ili 1 za prodyljavane na vyvejdane na uchastnici:" << endl;
- cin >> opcia;
- }
- int sredenRezultat = totalRezultat/i;
- int j = 0;
- // IZVLICHAME SAMO UCHASTNICITE KOITO SA OT SOU S REZULTAT PO VISOK OT SREDNIQ ZA OLIMPIADATA
- for(int a = 0 ; a < i ; a++){
- if(strstr(uchastnik[a].uchilishte , "SOU") != NULL && uchastnik[a].rezultat > sredenRezultat){
- uchastnikSOU[j] = uchastnik[a];
- j++;
- }
- }
- //OTPECHATVAME REZULTATA NA KONZOLATA
- cout << sredenRezultat;
- for(int b = 0 ; b < j ; b++){
- cout << uchastnikSOU[b].imena << ", " << uchastnikSOU[b].grad << ", " << uchastnikSOU[b].uchilishte << ", " << uchastnikSOU[b].rezultat << " tochki"<< endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement