Cdoj 25-point ball battle (penalty) problem Solving report

Source: Internet
Author: User

Simple string handling

Pit point, someone may not have a name (the name is empty)

Someone's name might be Blablablano.

But because the input guarantees that the last five characters are good (preceded by a space)

Because if the input means no good, no front must have a space

So you just have to judge whether the 6th, 7, 8 characters are ', ' n ', ' O '.

Of course, if the name appears empty, the result is good, the string length is less than 8, to determine the length of the string

After the above solution a little attention to the output format can be

#include <cstdio> #include <cstring>using namespace std;int t;char info[105];int Len;char result[2][20];int Score[2];void Initialize () {memset (info, 0, sizeof info), memset (result, 0, sizeof result), memset (score, 0, sizeof score); len = 0;} int main () {while (~SCANF ("%d", &t) && t) {Initialize (); and while (GetChar ()! = ' \ n '); for (int i = 0; i < T; + +) i) {gets (info), Len = strlen (info), if (Len > 8 && info[len-8] = = ' && info[len-7] = = ' n ' &&am P INFO[LEN-6] = = ' O ') result[i & 1][i >> 1] = ' X ', else Result[i & 1][i >> 1] = ' O ', ++score[i & 1]; }for (int i = 1; I <= t + 1 >> 1; ++i) printf ("%d", i);p UTS ("score"); if (T & 1) result[1][t >> 1] = '- ' for (int i = 0; i < 2; ++i) {for (int j = 0; J << 1 < T; ++j) Putchar (Result[i][j]), Putchar (");p rintf ("%d\ N ", Score[i]);}} return 0;}

Cdoj 25-point ball battle (penalty) problem Solving report

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.