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

只需要判断同一列的元素与前一列的差值都相等,就是homogeneous否则就不是

Posted by ACM_Hohai at 2008-11-04 15:50:34 on Problem 2941
#include<iostream>

using namespace std;

int data[1001][1001];
int dot[1001];

int main()
{
    int n;
    bool flag=true;
    while(cin>>n&&n!=0) {
        flag=true;
        for(int i=0;i<n;i++) {
            cin>>data[0][i];
            if(i>0) {
                dot[i]=data[0][i]-data[0][i-1];
            }
        }
        for(int j=1;j<n;j++) {
            for(int i=0;i<n;i++) {
                cin>>data[j][i];
                if(i>0) {
                    if(data[j][i]-data[j][i-1]!=dot[i]) {
                        flag=false;
                    }
                }
            }
        }
        if(flag) {
            cout<<"homogeneous"<<endl;
        }
        else
        {
            cout<<"not homogeneous"<<endl;
        }
    }
    return 1;
}

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