Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <string.h>
  2. #include <iostream>
  3. using namespace std;
  4. #define n=255;
  5. typedef struct squadra{
  6. char nome[20];
  7. int codice;
  8. int gf;
  9. int gs;
  10. }squadra;
  11.  
  12. int input_sq(squadra sq[], int j){
  13. cout<<"SQUADRA: ";
  14. cin>>sq[j].nome;
  15. cout<<"CODICE SQUADRA: ";
  16. cin>>sq[j].codice;
  17. cout<<"GOAL FATTI: ";
  18. cin>>sq[j].gf;
  19. cout<<"GOAL SUBITI: ";
  20. cin>>sq[j].gs;
  21. j++;
  22. return j;
  23. }
  24.  
  25. void ricerca(squadra sq[], int j){
  26. int cod;
  27. cout<<"CODICE: ";
  28. cin>>cod;
  29. for (int i=0; i<j; i++)
  30. {
  31. if(sq[i].codice==cod){
  32. cout<<"SQUADRA: "<<sq[i].nome;
  33. cout<<"\nGOAL FATTI: "<<sq[i].gf;
  34. cout<<"\nGOAL SUBITI: "<<sq[i].gs;
  35. }
  36. }
  37. }
  38. int main()
  39. {
  40. squadra squadre[255];
  41. int team=0;
  42. int scelta;
  43. do{
  44. cout<<"\n1) INSERISCI SQUADRA 2) CERCA SQUADRA 3) EXIT\n\n>> ";
  45. cin>>scelta;
  46. {
  47. if(scelta==1)
  48. team = input_sq(squadre,team);
  49. if(scelta==2)
  50. ricerca(squadre,team);
  51. }
  52. }while (scelta!=3);
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement