Skip to content
Snippets Groups Projects
Commit fc1dce6f authored by Fauzan Rifqy's avatar Fauzan Rifqy
Browse files

Bucket

parent 3716c46b
Branches
No related merge requests found
bucket.c 0 → 100644
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
int main(int argc, char* argv[]){
if(argc<3){
printf("You need input 3 arguments\n");
exit(-1);
}
int thread_count = strtol(argv[1], NULL, 10);
int n = strtol(argv[1], NULL, 10) * strtol(argv[2], NULL, 10);
int array[n];
printf("%d - %d\n", thread_count, n);
//bagi ke beberapa embercd
//foreach element in elements
#pragma omp parallel num_threads(thread_count);
//if mine(who, element)
//myElement.push(element)
//shorting
//short(myElement)
//if(!root)
//send(myElement, root)
//else
//receive(myElement, allThreads) --sortedly
//shorting all
return 0;
}
\ No newline at end of file
/* Copyrights http://www.programmingsimplified.com/c/source-code/c-program-insertion-sort */
/* insertion sort ascending order */
#include <stdio.h>
int main()
{
int n, array[1000], c, d, t;
printf("Enter number of elements\n");
scanf("%d", &n);
printf("Enter %d integers\n", n);
for (c = 0; c < n; c++) {
scanf("%d", &array[c]);
}
for (c = 1 ; c <= n - 1; c++) {
d = c;
while ( d > 0 && array[d] < array[d-1]) {
t = array[d];
array[d] = array[d-1];
array[d-1] = t;
d--;
}
}
printf("Sorted list in ascending order:\n");
for (c = 0; c <= n - 1; c++) {
printf("%d\n", array[c]);
}
return 0;
}
\ No newline at end of file
File added
omp_trap 0 → 100755
File added
File added
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment