zoukankan      html  css  js  c++  java
  • HDOJ 2539 点球大战

    注意应该判断字符串" no good"(NO前有空格)

    #include <iostream>
    #include <string>
    #include <stdio.h>
    #include <string.h>

    using namespace std;

    int main()
    {
        char a[20],b[20];
        int n;
        while(cin>>n&&n)
        {
            memset(a,'-',sizeof(a));
            memset(b,'-',sizeof(b));
            int m=(n+1)/2;
            int i=0;

            getchar();
            for(int j=0;j<n;j++)
            {
                string p,q;
                getline(cin,p);

                int nn=p.length();
                if(nn<7)
                  {
                      p="hello"+p;
                      nn=p.length();
                  }

                //cout<<p<<endl;

                q=p.substr(nn-8,8);

                //cout<<q<<endl;

                if(q!=" no good")
                {
                    if(i%2==1)
                        a[i/2]='O';
                    else
                        b[i/2]='O';
                }
                else if(q==" no good")
                {
                    if(i%2==1)
                        a[i/2]='X';
                    else
                        b[i/2]='X';
                }

                i++;
            }


                for(int k=0;k<m;k++)
                {
                    cout<<k+1<<" ";
                }
                int sum=0;
                cout<<"Score"<<endl;
                for(int k=0;k<m;k++)
                {
                    cout<<b[k]<<" ";
                    if(b[k]=='O')
                        sum++;
                }
                cout<<sum<<endl;
                sum=0;
                for(int k=0;k<m;k++)
                {
                    cout<<a[k]<<" ";
                    if(a[k]=='O')
                        sum++;
                }
                cout<<sum<<endl;
                sum=0;
        }
        return 0;
    }

  • 相关阅读:
    弄清变量名字空间
    Perl中文编码的处理
    了解魔符的含义
    Log::Minimal 小型可定制的log模块
    Perl – 文件测试操作符
    在源代码中使用Unicode字符
    editplus乱码charset的奇怪问题
    ASP.NET程序中常用代码汇总(一)
    ASP.NET程序中常用代码汇总(三)
    ASP.NET程序中常用代码汇总(二)
  • 原文地址:https://www.cnblogs.com/CKboss/p/3351108.html
Copyright © 2011-2022 走看看