Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdbool.h>
- void Add(int** arr, int r, int c, int value) {
- for (size_t i = 0; i < r; i++)
- {
- for (size_t j = 0; j < c; j++)
- arr[i][j] = value + rand() % 1000;
- }
- }
- void Print(int** arr, int r, int c) {
- printf("Price Count\n");
- for (size_t i = 0; i < r; i++)
- {
- for (size_t j = 0; j < c; j++)
- printf("%d\t", arr[i][j]);
- printf("\n");
- }
- }
- int main()
- {
- int r=6, c=2, value = 0;
- printf("Count product: ");
- scanf("%d", &r);
- //scanf("%d", &c);
- int ** arr = (int**) malloc (sizeof (int*) * r);
- for (int i = 0; i <r; i++) {
- arr [i] = (int*) malloc (sizeof (int)*c);
- }
- printf("Value: ");
- scanf("%d", &value);
- Add(arr, r, c, value);
- Print(arr, r, c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement