Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. using namespace std;
  7.    
  8.  
  9. int main(int argc, char** argv) {
  10.     int i,n, risp, conf, chiave, magliamax, magliamin;
  11.     float tempo[50];
  12.     int nummaglia[50];
  13.     string nummagliamax,nummagliamin;
  14.     double scarto, media, tmax=(-32768), tmin=32767, somma=0;
  15.     bool trovato;
  16.    
  17.    
  18.  
  19.    
  20.     cout<<"Inserisci il numero di concorrenti da registrare: ";
  21.     cin>>n;
  22.    
  23.     for(i=0;i<n;i++)
  24.     {
  25.         nummaglia[i] = (i+1);
  26.         cout<<"Inserisci il tempo del ciclista con  maglia "<<nummaglia[i]<<": ";
  27.         cin>>tempo[i];
  28.         somma+=tempo[i];
  29.         if(tempo[i]>tmax)
  30.         {
  31.             tmax=tempo[i];
  32.             magliamax=i+1;
  33.         }
  34.         if (tempo[i]<tmin)
  35.         {
  36.             tmin=tempo[i];
  37.             magliamin=i+1;
  38.         }  
  39.     }
  40.    
  41.     cout<<"Ricercare un concorrente? 1=no, altro valore=si: ";
  42.     cin>>risp;
  43.    
  44.     while(risp!=1)
  45.     {
  46.         cout<<"Inserire il numero di maglia del concorrente da cercare: ";
  47.         cin>>chiave;
  48.        
  49.         i=0;
  50.        
  51.         do
  52.         {
  53.             if(nummaglia[i]==chiave)
  54.             trovato=true;
  55.             else
  56.             i+=1;
  57.         }while(trovato==false && i<n);
  58.        
  59.         if (trovato==true)
  60.             cout<<"Il tempo del concorrente con maglia "<<nummaglia[i]<<" e' "<<tempo[i]<<endl;
  61.         else
  62.             cout<<"Il concorrente ricercato non e' stato trovato."<<endl;
  63.            
  64.         cout<<"Ricercare un nuovo concorrente? 1=no, altro valore=si: ";
  65.         cin>>risp;
  66.     }
  67.    
  68.     media=somma/n;
  69.    
  70.     for(i=0;i<n;i++)
  71.     {
  72.         cout<<"Lo scarto del concorrente con maglia "<<i+1<<" rispetto alla media è: "<<abs(tempo[i]-media)<<endl;
  73.     }
  74.     cout<<endl<<"Il tempo massimo e' "<<tmax<<" effettuato dal ciclista con maglia"<<magliamax<<"."<<endl<<"Il tempo minimo è "<<tmin<<" effettuato dal ciclista con maglia"<<magliamin<<".";
  75.        
  76.  
  77.  
  78.    
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement