Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:试一下用cin.

Posted by ssadwlll at 2008-03-30 13:45:21 on Problem 3561
In Reply To:试一下用cin. Posted by:keeng2008 at 2008-03-29 13:56:35
#include <iostream>
using namespace std;
int main()
{
    char ch;
    int t,i,j,n,m,k;
    int h,v,d;
    cin>>t;
    for(k=0;k<t;k++)
    {
        cin>>n>>m;
        int count=0,flag=1;
        while(cin>>ch&&ch=='.'&&count<(m*n-1))
            count++;
        count++;
        if(ch=='-'&&count!=n*m)
        {
            cin>>ch;
            count++;
            if(count%m!=0)
            {
                for(i=count%m;i<m;i++,count++)
                {
                    cin>>ch;
                    if(ch!='.'&&ch!='-')
                        flag=0;
                }

            }
            for(i=count;i<n*m;i++)
            {
                cin>>ch;
                if(ch!='.')
                    flag=0;
            }
        }
        else if(ch=='|'&&count!=m*n)
        {
           v=count;
           while(count<m*n)
           {
                cin>>ch;
                count++;
                if(ch=='|')
                {
                    if((count-v)%m!=0)
                    flag=0;
                }
                else if(ch!='.')
                    flag=0;
           }
        }
        else if(ch=='\\'&&count!=n*m)
        {
            d=count;
            while(count<n*m)
            {
                cin>>ch;
                count++;
                if(ch=='\\')
                {
                    if(count!=d)
                        flag=0;
                    else
                        d+=(m+1);
                }
                else if(ch!='.')
                    flag=0;
                if(count%m==0)
                    d+=(m+1);
            }
        }
        else if(ch=='/'&&count!=m*n)
        {
            h=count;
            if(count%m==0)
                h+=(m-1);
            while(count<n*m)
            {
                cin>>ch;
                count++;
                if(ch=='/')
                {
                    if(count!=h)
                        flag=0;
                    else
                        h+=m-1;
                }
                else if(ch!='.')
                    flag=0;
                if(count%m==0)
                    h+=(m-1);
            }
        }
        else if(count!=n*m)
            flag=0;
        if(flag)
            cout<<"CORRECT"<<endl;
        else
            cout<<"INCORRECT"<<endl;
    }
}
不行啊,好心人来瞧瞧

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator