HDU 2025查找最大元素
今天AA。。。。。。
#include<stdio.h>
#include<string.h>
int main( )
{
int max;
char str[105];
while( scanf( "%s",str ) != EOF )
{
int i = 0;
max = 0;
while( str[i] )
{
if( str[i] > max )
max = str[i];
++i;
}
i = 0;
while( str[i] )
{
printf( "%c",str[i] );
if( str[i] == max )
printf( "(max)" );
++i;
}
puts( "" );
}
return 0;
}
#include <stdio.h>
#include <string.h>
#define M max
int main ( )
{
int i,j,m,n;
char s[1000] = {0};
while ( scanf ( "%s",s ) ==1 )
{
m = 0;
i = 0;
while ( s[i] != 0 ){
if ( s[i] > m )
m = s[i];
++i;
}
n = strlen ( s );
for ( i = 0 ; i < n ; ++i )
{
if ( s[i] == m )
{
n = n + 5;
for ( j = n; j > i + 5; --j )
{
s[j] = s[ j - 5 ];
}
s[i+1] = '(';
s[i+2] = 'm';
s[i+3] = 'a';
s[i+4] = 'x';
s[i+5] = ')';
i = i + 5;
}
}
printf ( "%s\n",s );
}
return 0;
}
本人还是新手 ,转载请注明来自Lvsi‘s home
浙公网安备 33010602011771号