Skip to content

Instantly share code, notes, and snippets.

View frmsaul's full-sized avatar

Saul Fuhrmann frmsaul

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<html>
<body>
<h1> Hello </h1>
</body>
</html>
void printArr(int arr[], int len){
if(len == 0){
printf("\n");
return;
}
printf("%d,",arr[0]);
printArr(arr + 1, len - 1);
}
@frmsaul
frmsaul / "C++ code to insert an element into middle of array"
Created March 5, 2015 01:49
"C++ code to insert an element into middle of array"
//insert integer x into index ind
void insert_to_arr(int* arr, int arr_size, int x, int ind){
arr = (int*)realloc(arr, sizeof(int) * (arr_size + 1) );
print_array(arr, arr_size + 1);
for(int i = arr_size; i > ind; i--){
arr[i] = arr[i - 1];
}
arr[ind] = x;
}
// your_objects is vector of pair<string, vector<int> >
// PQ is your priority_queue
int vector_counter = 0;
for(int i = 0; i < 10; i++){
PQ.push(your_pairs[vector_counter]);
vector_counter++;
}
while(vector_counter < your_objects.size()){
PQ.push(your_pairs[vector_counter]);
PQ.pop();