Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int main()
- {
- int *mas=new int[25];
- int N;
- cout << "Input N" << endl;
- cin >> N;
- int *p = new int[N];
- cout << "Input array" << endl;
- for (int i = 0; i < N; i++)
- {
- cin >> p[i];
- cout << i << " Element of array = " << p[i] << endl;
- }
- for (int i = 0; i < N; i++)
- {
- if (p[i] == p[i + 1]||p[i]==p[i+i])
- {
- mas[i] = p[i];
- }
- }
- for (int i = 0; i < N; i++)
- {
- cout << mas[i];
- }
- _getch();
- return 0;
- }
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- int main()
- {
- const size_t N = 10;
- int a[N];
- std::srand( ( unsigned int )std::time( nullptr ) );
- for ( auto &x : a ) x = std::rand() % N;
- for ( auto x : a ) std::cout << x << ' ';
- std::cout << std::endl;
- for ( size_t i = 0; i < N; i++ )
- {
- size_t j = 0;
- while ( j != i && a[j] != a[i] ) j++;
- if ( j++ == i )
- {
- while ( j < N && a[j] != a[i] ) j++;
- if ( j != N ) std::cout << a[i] << ' ';
- }
- }
- std::cout << std::endl;
- return 0;
- }
- 1 2 9 5 0 5 2 4 1 8
- 1 2 5
- std::sort( a, a + N );
- #include <algorithm>
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <algorithm>
- int main()
- {
- const size_t N = 10;
- int a[N];
- std::srand( ( unsigned int )std::time( nullptr ) );
- for ( auto &x : a ) x = std::rand() % N;
- for ( auto x : a ) std::cout << x << ' ';
- std::cout << std::endl;
- std::sort( a, a + N );
- for ( size_t i = 0; i < N; )
- {
- size_t j = i + 1;
- while ( j < N && a[i] == a[j] ) j++;
- if ( j - i > 1 )
- {
- std::cout << a[i] << ' ';
- }
- i = j;
- }
- std::cout << std::endl;
- return 0;
- }
- for (int i = 0; i < N; i++)
- {
- if (p[i] == p[i + 1]||p[i]==p[i+i])
- {
- mas[i] = p[i];
- }
- }
- if (p[i] == p[i + 1]||p[i]==p[i+i])
Add Comment
Please, Sign In to add comment