Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- ////////////////////////////////////////////////////////
- int main()
- {
- int n = 1234;
- scanf("%d", &n);
- printf("n = %d\n", n);
- }
- /*
- #include <stdio.h>
- #include <cstdlib>
- #include <ctime>
- int size = 20,
- *arr = (int*)malloc(80), // new int[size];
- count = 0;
- void sortirovka(int* arr, int size);
- void randomarray(int* a, int s);
- ////////////////////////////////////////////////////////
- int main()
- {
- randomarray(arr, size);
- sortirovka (arr, size);
- for(int i = 0; i < size; i++)
- {
- printf("%d ", arr[i]);
- }
- printf("\ncounter = %d ", count);
- }
- //______________________________________________
- //______________________________________________
- void sortirovka(int* arr, int size)
- {
- int temp;
- for (int i = 0; i < size - 1; i++)
- {
- for (int j = 0; j < size - i - 1; j++)
- {
- if (arr[j] > arr[j + 1])
- {
- temp = arr[j];
- arr[j] = arr[j + 1];
- arr[j + 1] = temp;
- count ++;
- }
- }
- }
- }
- //////////////////////////////////////////////////////////////
- void randomarray(int* a, int s)
- {
- // srand(time(0) );
- for(int i = 0; i < size; i++)
- {
- arr[i] = rand() % 100;
- printf("%d ", arr[i]);
- }
- printf("\n");
- }
- */
- /*
- #include <stdio.h>
- #include <cstdlib>
- #include <ctime>
- void sortirovka(int* arr, int size);
- void randomarray(int* a, int s);
- int size = 20,
- *arr = (int*)malloc(80); // new int[size];
- ////////////////////////////////////////////////////////
- int main()
- {
- randomarray(arr, size);
- sortirovka (arr, size);
- for(int i = 0; i < size; i++)
- {
- printf("%d ", arr[i]);
- }
- }
- //______________________________________________
- //______________________________________________
- void sortirovka(int* arr, int size)
- {
- int temp;
- for (int i = 0; i < size - 1; i++)
- {
- for (int j = 0; j < size - i - 1; j++)
- {
- if (arr[j] > arr[j + 1])
- {
- temp = arr[j];
- arr[j] = arr[j + 1];
- arr[j + 1] = temp;
- }
- }
- }
- }
- //////////////////////////////////////////////////////////////
- void randomarray(int* a, int s)
- {
- // srand(time(0) );
- for(int i = 0; i < size; i++)
- {
- arr[i] = rand() % 100;
- printf("%d ", arr[i]);
- }
- printf("\n");
- }
- */
- /*
- #include <stdio.h>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void sortirovka(int* arr, int size, int temp);
- void randomarray(int* a, int s);
- int size = 20;
- int* arr = new int[size];
- int temp;
- int main()
- {
- randomarray(arr, size);
- sortirovka(arr, size, temp);
- for (int i = 0; i < size; i++)
- {
- printf("%d ", arr[i]);
- }
- }
- //______________________________________________
- //______________________________________________
- void sortirovka(int* arr, int size, int temp)
- {
- for (int i = 0; i < size - 1; i++)
- {
- for (int j = 0; j < size - i - 1; j++)
- {
- if (arr[j] > arr[j + 1])
- {
- temp = arr[j];
- arr[j] = arr[j + 1];
- arr[j + 1] = temp;
- }
- }
- }
- }
- void randomarray(int* a, int s) {
- srand(time(0));
- for (int i = 0; i < size; i++)
- {
- arr[i] = rand() % 100;
- printf("%d ", arr[i]);
- }
- printf("\n");
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement