Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4. #include <locale.h>
  5.  
  6. int main()
  7. {
  8. setlocale(LC_ALL, "RUS");
  9. SetConsoleCP(1251);
  10. SetConsoleOutputCP(1251);
  11.  
  12. int N;
  13. printf("Введите кол-во элементов массива: ");
  14. scanf("%d", &N);
  15. int *A = NULL;
  16. A = (int*) malloc(N * sizeof(int));
  17. if(A==NULL)
  18. {
  19. printf("Память не выделена!");
  20. exit(1);
  21. }
  22.  
  23. printf("Введите элементы массива: ");
  24. int i;
  25. for (i = 0; i < N; i++)
  26. {
  27. scanf("%d", &A[i]);
  28. }
  29.  
  30. int j;
  31. int counter = 0;
  32. for (i = 0; i < N; i++)
  33. {
  34. for (j = 0; j < N; j++)
  35. {
  36. if (A[i]==A[j])
  37. counter++;
  38. }
  39. if (counter >= 2)
  40. {
  41. printf("%d", A[i]);
  42. break;
  43. }
  44. }
  45. free(A);
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement