Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- void set(uint64_t* arr, int width, int height, uint64_t value, int x, int y)
- {
- if (arr == NULL)
- return;
- if (x < 0 || x >= width)
- return;
- if (y < 0 || y >= height)
- return;
- int index = y * width + x;
- arr[index] = value;
- }
- uint64_t get(const uint64_t* arr, int width, int height , int x, int y, uint64_t* result)
- {
- if (arr == NULL || result == NULL)
- return -1;
- if (x < 0 || x >= width)
- return -1;
- if (y < 0 || y >= height)
- return -1;
- int index = y * width + x;
- *result = arr[index];
- return 1;
- }
- void show(const uint64_t* arr, int width, int height)
- {
- for (int r = 0; r < height; r++)
- {
- for (int c = 0; c < width; c++)
- {
- uint64_t value;
- get(arr, width, height, c, r, &value);
- printf("%d ", value);
- }
- printf("\n");
- }
- }
- uint64_t power(int num, int wyk)
- {
- uint64_t result = 1;
- for (int i = 0; i < wyk; i++)
- {
- result *= num;
- }
- return result;
- }
- int main()
- {
- uint64_t tab[5 * 10];
- int i, j;
- // void set(unsigned long int* arr, int width, int height, unsigned long int value, int x, int y)
- for (i = 0; i < 5; i++)
- {
- for (j = 0; j < 10; j++)
- {
- set(tab, 10, 5, ((i+1) * power(10, j+1)), j, i);
- }
- }
- show(tab, 10, 5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement