HDU 4167 user names

Source: Internet
Author: User

I started to use map for a purely simulated question, but it has been wa for a long time.

There may be multiple spaces between names. At first, I searched from the left to the Right to overwrite the space position. But to the second space, I exited the loop and kept wa, switch to search from right to left, find the first one, and then exit. Then, it's over ............

I am wrong in the blank area of "A single blank space". This is a problem with English proficiency .................., I always thought it was a space.

View code

# Include <iostream>
# Include <algorithm>
Using Namespace STD;
Struct Name
{
Char STR [ 100 ];
Int K;
} NN [ 300 ];
Int Num, maxlen;
Int Findd ( Char * S)
{
For ( Int I = 0 ; I <num; I ++)
{
If (Strcmp (S, NN [I]. Str) = 0 )
{
NN [I]. K ++;
Return NN [I]. K;
}
}
Strcpy (NN [num]. STR, S );
NN [num ++]. k = 0 ;
Return 0 ;
}
Int Digit ( Int K)
{
Int S = K, t = 0 ;
While (S! =0 )
{
S/= 10 ;
T ++;
}
Return T;
}
Int Main ()
{
Int N, CAS = 0 ;
Char Ss [ 300 ], St [ 100 ];
While (Scanf ( " % D " , & N, & maxlen) = 2 & (N | maxlen ))
{
Getchar ();
Num = 0 ;
Printf ( " Case % d \ n " , ++ CAS );
For ( Int I =0 ; I <n; I ++)
{
Gets (SS );
Int Len = strlen (SS );
Int LAC = len- 1 ;
While (Ss [LAC]! = ' ' )
LAC --;
If (Isupper (ss [ 0 ])
St [ 0 ] = Ss [ 0 ] + 32 ;
Else St [ 0 ] = Ss [ 0 ];
Int Len1 = 1 ;
For ( Int J = LAC + 1 ; J <Len & len1 <maxlen; j ++)
{
If (Isupper (ss [J])
St [len1 ++] = ss [J] + 32 ;
Else If (Islower (ss [J])
St [len1 ++] = ss [J];
}
St [len1] = ' \ 0 ' ;
Int K = findd (ST );
If (K = 0 )
{
Puts (ST );
Continue ;
}
Int M = digit (K), Le = maxlen-len1;
If (Len1 + M <= maxlen)
{
Printf ( " % S % d \ n " , St, k );
Continue ;
}
St [len1-m + le] = ' \ 0 ' ;
Printf ( " % S % d \ n " , St, k );
}
}
Return 0 ;
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.