Advertisement
lorincmate

Untitled

Sep 12th, 2016
2,598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Készítsen menüt, amelyben a menüpontok a következők:
  3. 1. Tomb feltoltese
  4. 2. Legnagyobb ertek meghatarozasa
  5. 3. Kilepes (q)
  6. A tömb 5 int szám.
  7. */
  8.  
  9. #include <conio.h>
  10. #define ESC 0X1B
  11. void bekeres (int*);
  12. int maximum (int *p1);
  13. int tmb[5];
  14. int main ()
  15. {
  16.     int x;
  17.     while (1)
  18.     {
  19.     system("cls");
  20.     printf("Press a key. Escape to EXIT\n");
  21.     printf ("1.  Tomb feltoltese\n");
  22.     printf ("2.  Legnagyobb ertek meghatarozasa\n");
  23.     printf ("3.  Kilepes (ESC)\n");
  24.     x=getch ();
  25.     switch (x)
  26.     {case '1': bekeres(tmb); break;
  27.      case '2': maximum (tmb);  break;
  28.     }
  29.     if (x==ESC) break;
  30.     }
  31.     return 0;
  32. }
  33.  
  34. void bekeres (int* p)
  35. {
  36.     int i;
  37.     system("cls");
  38.     printf ("Kerem az elso erteket\n");
  39.     scanf ("%i",p);
  40.     p++;
  41.     printf ("Kerem a masodik erteket\n");
  42.     scanf ("%i",p);
  43.     p++;
  44.     printf ("Kerem a harmadik erteket\n");
  45.     scanf ("%i",p);
  46.     p++;
  47.     printf ("Kerem a negyedik erteket\n");
  48.     scanf ("%i",p);
  49.     p++;
  50.     printf ("Kerem az otodik erteket\n");
  51.     scanf ("%i",p);
  52.     p++;
  53.     getch();
  54. }
  55.  
  56. int maximum (int *p2)
  57. {
  58.     system("cls");
  59.     int max=-2e9,i;
  60.     for (i=0;i<5;i++,p2++)
  61.         if (max<*p2) max=*p2;
  62.     printf("A maximum ertek: %i",max);
  63.     getch();                        // vár
  64.     return max;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement