/* Phase 1 fills in the arrays, may be repeated */ bool phase1(rvm_cfg_t *cfg, test_state_t *state) { //fill_arr doesn't need to know about rvm fill_arr(state->arr0, 0, ARR0_SIZE); fill_arr(state->arr1, 1, ARR1_SIZE); return true; }
int main(int argc, char **argv) { if (argc != 3) { printf("usage: %s <server-address> <server-port>\n", argv[0]); return EXIT_FAILURE; } fprintf(stderr, "initialize\n"); rvm_cfg_t* cfg = initialize_rvm(argv[1], argv[2]); fprintf(stderr, "rvm_alloc\n"); int *safe_arr0 = (int*)rvm_alloc(cfg, ARR_SIZE*sizeof(int)); fprintf(stderr, "rvm_alloc done\n"); CHECK_ERROR(safe_arr0 == NULL, ("FAILURE: Failed to allocate array outside of a txn - %s\n", strerror(errno))); fprintf(stderr, "rvm_txn_begin\n"); rvm_txid_t txid = rvm_txn_begin(cfg); CHECK_ERROR(txid < 0, ("FAILURE: Could not start transaction - %s\n", strerror(errno))); fprintf(stderr, "rvm_alloc\n"); int *safe_arr1 = (int*)rvm_alloc(cfg, ARR_SIZE*sizeof(int)); CHECK_ERROR(safe_arr1 == NULL, ("Failed to allocate array inside a txn - %s", strerror(errno))); memset(safe_arr0, 0, ARR_SIZE*sizeof(int)); memset(safe_arr1, 0, ARR_SIZE*sizeof(int)); fill_arr(safe_arr0); fill_arr(safe_arr1); // fprintf(stderr, "Check txn commit before commit\n"); // CHECK_ERROR(check_txn_commit(cfg, txid) == true, // ("FAILURE: data got through before commit - %s", strerror(errno))); fprintf(stderr, "commit\n"); CHECK_ERROR(!rvm_txn_commit(cfg, txid), ("FAILURE: Failed to commit transaction - %s", strerror(errno))); fprintf(stderr, "Check txn commit after commit\n"); CHECK_ERROR(check_txn_commit(cfg, txid) == false, ("FAILURE: commit did not get through - %s", strerror(errno))); printf("Success!\n"); return EXIT_SUCCESS; }
int main() { int array0[ARR_SIZE], array1[ARR_SIZE]; fill_arr(array0, DESC); duplicate_arr(array0, array1); sort_select(array0); sort_buble(array1); return 0; }
void heap_arr_insert (int *head, int x, size_t *heap_size, size_t *arr_size) { if (*heap_size == *arr_size) { *arr_size *= 2; realloc(head, sizeof(int) * (*arr_size)); fill_arr(head, *heap_size, *arr_size); } size_t adj_heap_size = (*heap_size)++; head[adj_heap_size] = x; bubble_up(head, adj_heap_size); return; }
int main(void) { double source[ROWS][COLS]; double target[ROWS][COLS]; fill_arr(source); copy_arr(source, target); print_ptr(source); print_ptr(target); return 0; }
extract_num_bucket(node **bucket, int *arr) { int arr_curr_index = 0, i; for(i = 0; i < BUCKETSIZE; i++){ if(bucket[i] == NULL){ continue; }else{ fill_arr(bucket[i], arr, &arr_curr_index); del_bucket_list(bucket[i]); bucket[i] = NULL; } } }
int main() { int local_int; int local_arr[10]; int a = 1, b = 2; int result; int ind1 = 0, ind2 = 9; local_arr[ind1] = 14; local_arr[ind2] = 15; global_arr[ind1] = 13; global_arr[ind2] = 12; print local_arr[ind1]; // should be 0xe print local_arr[ind2]; // should be 0xf print global_arr[ind1]; // should be 0xd print global_arr[ind2]; // should be 0xc result = local_arr[9]; local_arr[9] = 4; local_arr[0] = 2; local_arr[a + b] = 8; print local_arr[a + b]; // should be 0x8 global_arr[a + b] = 4; print global_arr[a + b]; // should be 0x4 local_int = 14; // should be 0xe print local_int; global_int = 15; // should be 0xf print global_int; fill_arr(2, local_arr, 10); fill_arr(8, local_arr, 11); fill_arr(2, global_arr, 12); fill_arr(8, global_arr, 13); print local_arr[2]; // should be 0xa print local_arr[8]; // should be 0xb print global_arr[2]; // should be 0xc print global_arr[8]; // should be 0xd print fill_arr(5, local_arr, 5); // should be 0x5 print fill_arr(5, global_arr, 6); // should be 0x6 //print result; return result; }
int main() { int n; if (scanf("%d", &n) != 1) { printf("Invalid input!"); return 1; } int numbers[n]; fill_arr(numbers, n); int i, j, start = 0, end = 0; int bestEnd = 1, bestCount = 0; printf("\n"); for (i = 1; i <= n; i ++) { int count = 0; if (numbers[i] > numbers[i - 1]) { end++; } else { for (j = start; j <= end; j++) { printf("%d ", numbers[j]); } printf("\n"); end++; count = end - start; start = end; } if (i == n) { for (j = start; j < end; j++) { printf("%d ", numbers[j]); } count = end - start; } if (bestCount < count) { bestCount = count; bestEnd = end; } } printf("\nLongest: "); for (i = bestEnd - bestCount; i < bestEnd; i++) { printf("%d ", numbers[i]); } printf("\n"); return 0; }
int *init_heap (size_t len) { int *ret = malloc(len * sizeof(int)); fill_arr(ret, 0, len); return ret; }
int main() { int n; if (scanf("%d", &n) != 1) { printf("Invalid input!"); return 1; } int numbers[n]; fill_arr(numbers, n); int i, r, start = 0, finish = 0; int bestEnd = 1, bestCount = 0; printf("\n"); for (i = 1; i <= n; i ++) { int count = 0; if (numbers[i] > numbers[i - 1]) { finish++; } else { for (r = start; r <= finish; r++) { printf("%d ", numbers[r]); } printf("\n"); finish++; count = finish - start; start = finish; } if (i == n) { for (r = start; r < finish; r++) { printf("%d ", numbers[r]); } count = finish - start; } if (bestCount < count) { bestCount = count; bestEnd = finish; } } printf("\nLongest: "); for (i = bestEnd - bestCount; i < bestEnd; i++) { printf("%d ", numbers[i]); } printf("\n"); return 0; }