Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define ROWS 8
- #define COLS 8
- //REPLACES PART OF AN ARRAY WITH ZEROS, HAVE TO FIGURE OUT HOW TO DO IT FOR DIFFERENT PARTS OF ARRAY
- void pop_arr(int r,int c,int a[r][c]);
- void pr_arr(int r,int c,int a[r][c]);
- void change_arr(int r,int c,int a[r][c]);
- int main()
- {
- int result,one[ROWS][COLS];
- pop_arr(ROWS,COLS,one);
- pr_arr(ROWS,COLS,one);
- change_arr(ROWS,COLS,one);
- pr_arr(ROWS,COLS,one);
- return 0;
- }
- void pop_arr(int r,int c,int a[r][c])
- {
- int i,j;
- for(i=0;i<r;i++)
- {
- for(j=0;j<c;j++)
- {
- a[i][j]= rand()%10;
- }
- }
- }
- void pr_arr(int r,int c,int a[r][c])
- {
- int i,j;
- for(i=0;i<r;i++)
- {
- for(j=0;j<c;j++)
- {
- printf("%d\t",a[i][j]);
- }
- printf("\n");
- }
- }
- void change_arr(int r,int c,int a[r][c])
- {
- int i,j;
- for(i=0;i<r;i++)
- {
- for(j=0;j<c;j++)
- {
- //if((i>r/2)||(j<i||j>c-i))//all zeros, expept over main&&dop diagonal
- if((i<r/2&&j>=c-i) ||(i>=r/2&&j>=c/2-i))
- a[i][j]=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement