Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language, for a given integer dimension array a[ 100], it is required to assign negative values to the elements with odd subscripts and positive values to the elements with even subscripts.
C language, for a given integer dimension array a[ 100], it is required to assign negative values to the elements with odd subscripts and positive values to the elements with even subscripts.
# include & ltstdio.h & gt

# include & ltstdlib.h & gt

# include & lttime.h & gt

int main()

{ int i,a[ 100];

srand(time(0));

for(I = 0; I< 100; i++)

{ a[i]=i%2? -(rand()% 100+ 1):rand()% 100+ 1;

printf("%5d ",a[I]);

}

Returns 0;

}