Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5. #define MAX_VEC 50
  6.  
  7. int main ()
  8. {
  9. int v[MAX_VEC],n;
  10. char opt;
  11. do
  12. { system("cls");
  13. printf("Meniu problema" "\n___________");
  14. printf("\nA. Citire");
  15. printf("\nB. Afisare");
  16. printf("\nX. Iesire\n\n\n");
  17. opt = toupper(getch());
  18.  
  19. switch(opt)
  20. {
  21. case 'A':
  22. citire(v);
  23. getch();
  24. break;
  25. case 'B':
  26. afisare(n,v);
  27. getch();
  28. break;
  29. case 'X':
  30. exit(0);
  31. default:
  32. printf("Optiune inexistenta. Reincercati.");
  33. getch();
  34. break;
  35. }
  36. }
  37. while(1);
  38. return 0;
  39. }
  40.  
  41. citire(int v[])
  42. {
  43. int i,n;
  44. printf("Introduceti numarul de elemente al vectorului: ");
  45. scanf("%d",&n);
  46. for(i=0;i<n;i++)
  47. {
  48. printf("v[%d]=",i);
  49. scanf("%d",&v[i]);
  50. }
  51. return n;
  52. }
  53.  
  54. afisare(int n, int v[])
  55. {
  56. int i;
  57. printf("Elementele din vector sunt: ");
  58. for(i=0;i<n;i++)
  59. printf("v[%d]=%d\n",i,v[i]);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement