Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <stddef.h>
- #include <time.h>
- int randomazer (int max, int min){
- float random;
- random = rand();
- random = (random / RAND_MAX) * (max-min) + min;
- return((int)random);
- }
- void swap (int *a1, int *a2)
- {
- int tmp = *a1;
- *a1 = *a2;
- *a2 = tmp;
- }
- int main (void){
- srand(time(NULL));
- int N, i, k1, k2, note;
- scanf ("%d", &N);
- int x[N+1];
- for (i=0 ; i<N ; i++){
- x [i] = randomazer (0, 100);
- printf ("%d ", x[i]);
- }
- k1 = (N-2)*5;
- k2 = (N-3)*5;
- if (k1%10 == 0){
- i = k1/10;
- note = 1; //only left
- }
- if (k2%10 == 0){
- i = k2/10;
- note = 2; //left and right
- }
- printf ("\n %d \n", i);
- if (note == 2){
- while (i != 0){
- if ((a[i]<a[2*i+1])||(a[i]<a[2*i+2])){
- if (a[2*i+1]>=a[2*i+1]){
- swap (&a[i], &a[2*i+1]);
- //again this function while
- }
- else{
- swap (&a[i], &a[2*i+2]);
- //again this function
- }
- }
- i--;
- }
- }
- if(note == 1){
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment