Commit 16e87b13 by glkink

Add new file

parents
Showing with 70 additions and 0 deletions
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int printRandoms(int lower, int upper,
int count)
{
int i;
for (i = 0; i < count; i++) {
int num = (rand() %
(upper - lower + 1)) + lower;
return num;
}
}
int main() {
int row,col, i, j,V;
static int cnt=0;
printf("\n Enter no. of rows ....\n");
scanf("%d",&row);
printf("\n Enter no. of cols ....\n");
scanf("%d",&col);
printf("\n Enter range ....\n");
scanf("%d",&V);
int arr[row][col];
for(int j=0;j<row;j++){
for(int i=0;i<col;i++)
{
if(col%2==0){
if(i <= (col/2)-1)
{
arr[i][j] = printRandoms((-1)* V, V, 1);
}
else
{
arr[i][j] = (-1) * (arr[abs(i - (col-1))][j]);
}
}
else
{
if(i <= (col/2))
{
arr[i][j] = printRandoms((-1)* V, V, 1);
}
else
{
arr[i][j] = (-1) * (arr[abs(i - (col))][j]);
}
}
}}
printf("\n printing the elements ....\n");
for(i=0;i<row;i++)
{
printf("\n");
for (j=0;j<col;j++)
{
printf("%d\t",arr[i][j]);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment