Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <time.h>
- void Afisare(int a[],int n) {
- for (int i = 0; i < n; i++) {
- printf("%d ", a[i]);
- }
- printf("\n");
- }
- void Sortare(int a[],int b[],int n) {
- int glass;
- for (int i = 0; i < n - 1; i++) {
- for (int j = i + 1; j < n; j++) {
- if (a[i] > a[j]) {
- glass = a[i];
- a[i] = a[j];
- a[j] = glass;
- glass = b[i];
- b[i] = b[j];
- b[j] = glass;
- }
- }
- }
- }
- void MakeThemUnic(int vector1[], int vectorDeControl[], int n) {
- int k;
- for (int i = 0; i < n; i++) {
- vectorDeControl[i] = vector1[i];
- }
- for (int i = 0; i < n; i++) {
- k = 0;
- for (int j = 0; j < n; j++) {
- if (vector1[i] == vectorDeControl[j]) {
- k++;
- while (vector1[i] == vectorDeControl[j] && k >= 2) {
- vector1[j] = rand() % 11 + 1;
- vectorDeControl[j] = vector1[j];
- }
- }
- }
- }
- }
- void endHour(int vector1[], int vector2[], int n) {
- time_t t;
- srand(unsigned(time(&t)));
- for (int i = 0; i < n; i++) {
- vector2[i] = vector1[i] + rand() % 2 + 1;
- }
- }
- void main() {
- time_t t;
- srand(unsigned(time(&t)));
- const int n = 7;
- int a[n];
- int b[n];
- int c[n];
- for (int i = 0; i < n; i++) {
- a[i] = rand() % 11 + 1;
- b[i] = rand() % 11 + 2;
- }
- MakeThemUnic(a, c, n);
- endHour(a, b, n);
- Afisare(a, n);
- Afisare(b, n);
- Sortare(a, b, n);
- printf("\nSortat : \n");
- Afisare(a, n);
- Afisare(b, n);
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement