Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- using namespace std;
- int main(int argc, char** argv) {
- int i,n, risp, conf, chiave, magliamax, magliamin;
- float tempo[50];
- int nummaglia[50];
- string nummagliamax,nummagliamin;
- double scarto, media, tmax=(-32768), tmin=32767, somma=0;
- bool trovato;
- cout<<"Inserisci il numero di concorrenti da registrare: ";
- cin>>n;
- for(i=0;i<n;i++)
- {
- nummaglia[i] = (i+1);
- cout<<"Inserisci il tempo del ciclista con maglia "<<nummaglia[i]<<": ";
- cin>>tempo[i];
- somma+=tempo[i];
- if(tempo[i]>tmax)
- {
- tmax=tempo[i];
- magliamax=i+1;
- }
- if (tempo[i]<tmin)
- {
- tmin=tempo[i];
- magliamin=i+1;
- }
- }
- cout<<"Ricercare un concorrente? 1=no, altro valore=si: ";
- cin>>risp;
- while(risp!=1)
- {
- cout<<"Inserire il numero di maglia del concorrente da cercare: ";
- cin>>chiave;
- i=0;
- do
- {
- if(nummaglia[i]==chiave)
- trovato=true;
- else
- i+=1;
- }while(trovato==false && i<n);
- if (trovato==true)
- cout<<"Il tempo del concorrente con maglia "<<nummaglia[i]<<" e' "<<tempo[i]<<endl;
- else
- cout<<"Il concorrente ricercato non e' stato trovato."<<endl;
- cout<<"Ricercare un nuovo concorrente? 1=no, altro valore=si: ";
- cin>>risp;
- }
- media=somma/n;
- for(i=0;i<n;i++)
- {
- cout<<"Lo scarto del concorrente con maglia "<<i+1<<" rispetto alla media è: "<<abs(tempo[i]-media)<<endl;
- }
- cout<<endl<<"Il tempo massimo e' "<<tmax<<" effettuato dal ciclista con maglia"<<magliamax<<"."<<endl<<"Il tempo minimo è "<<tmin<<" effettuato dal ciclista con maglia"<<magliamin<<".";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement