#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main ( )
{ int a[ 5 ] [ 5 ] ;
int b[ 5 ] ;
srand ( ( unsigned ) time ( NULL ) ) ;
int * p= a[ 0 ] ;
int i, j;
for ( i= 0 ; i<= 5 * 5 ; i++ )
* ( p+ i) = rand ( ) % 100 + 1 ;
printf ( "orginal array is:\n" ) ;
for ( i= 0 ; i< 5 * 5 ; i++ )
{ printf ( "%d " , * ( p+ i) ) ;
if ( ( i+ 1 ) % 5 == 0 )
puts ( "\n" ) ;
}
for ( i= 0 ; i< 5 ; i++ )
{
b[ i] = a[ i] [ 0 ] ;
for ( j= 1 ; j< 5 ; j++ )
if ( a[ i] [ j] > b[ i] )
b[ i] = a[ i] [ j] ;
}
for ( i= 0 ; i< 5 ; i++ )
{
for ( j= 0 ; j< 5 ; j++ )
if ( a[ i] [ j] == b[ i] )
a[ i] [ j] = 0 ;
}
printf ( "————————————\n" ) ;
for ( i= 0 ; i< 5 ; i++ )
{ for ( j= 0 ; j< 5 ; j++ )
{
printf ( "%-3d" , a[ i] [ j] ) ;
}
puts ( "\n" ) ;
}
}
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main ( )
{ int a[ 5 ] [ 5 ] ;
srand ( ( unsigned ) time ( NULL ) ) ;
int * p= a[ 0 ] ;
int i, j;
for ( i= 0 ; i<= 5 * 5 ; i++ )
* ( p+ i) = rand ( ) % 100 + 1 ;
printf ( "orginal array is:\n" ) ;
for ( i= 0 ; i< 5 * 5 ; i++ )
{ printf ( "%d " , * ( p+ i) ) ;
if ( ( i+ 1 ) % 5 == 0 )
puts ( "\n" ) ;
}
int tmp;
for ( i= 0 ; i< 5 ; i++ )
for ( j= 0 ; j< 4 ; j++ )
if ( a[ i] [ j] > a[ i] [ j+ 1 ] )
{
tmp= a[ i] [ j] ;
a[ i] [ j] = a[ i] [ j+ 1 ] ;
a[ i] [ j+ 1 ] = tmp;
}
printf ( "————————————\n" ) ;
for ( i= 0 ; i< 5 ; i++ )
{ for ( j= 0 ; j< 4 ; j++ )
{
printf ( "%-3d" , a[ i] [ j] ) ;
}
puts ( "\n" ) ;
}
return 0 ;
}