Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- #include <locale.h>
- int main()
- {
- setlocale(LC_ALL, "RUS");
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int N;
- printf("Введите кол-во элементов массива: ");
- scanf("%d", &N);
- int *A = NULL;
- A = (int*) malloc(N * sizeof(int));
- if(A==NULL)
- {
- printf("Память не выделена!");
- exit(1);
- }
- printf("Введите элементы массива: ");
- int i;
- for (i = 0; i < N; i++)
- {
- scanf("%d", &A[i]);
- }
- int j;
- int counter = 0;
- for (i = 0; i < N; i++)
- {
- for (j = 0; j < N; j++)
- {
- if (A[i]==A[j])
- counter++;
- }
- if (counter >= 2)
- {
- printf("%d", A[i]);
- break;
- }
- }
- free(A);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement