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

真郁闷,哪位老大看看怎么错了?

Posted by OverJupiter at 2003-11-15 22:38:47 on Problem 1550
#include <iostream.h>

int n, a[11000], num, minute, second, speed, inclination, b[3];

bool isStart(int pos) {
    if ((a[pos] == 4 || a[pos] == 5) && (a[pos+1] == 4 || a[pos+1] == 5)
     && (a[pos+2] == 0 || a[pos+2] == 1) && (a[pos+3] == 8 || a[pos+3] == 9))
        return true;
    else return false;
}

void get(int pos) {
    for (int i = 0; i < 3; i++){
        if (a[pos] == 4 || a[pos] == 5)
            b[i] = 0;
        else b[i] = 1;
        pos += 2;
    }
}

void solve(int pos) {
    minute = (pos / 3 / 60);
    second = (pos / 3 % 60);
    if (minute < 10)
        cout << "0" << minute;
    else cout << minute;
    cout << ":";
    if (second < 10)
        cout << "0" << second;
    else cout << second;
    pos += 4;
    get(pos);
    pos += 6;
    speed = b[2] * 4 + b[1] * 2 + b[0];
    get(pos);
    inclination = b[2] * 4 + b[1] * 2 +b[0];
    cout << " Speed " << speed << " Inclination " << inclination << endl;
}

int main() {
    int i, j;
    cin >> n;
    for (i = i; i <= n; i++) {
        cout << "Program " << i << endl;
        for (num = 0; ;) {
            cin >> a[num];
            if (a[num] == 10)
                break;
            else if (a[num] < 0 || a[num] > 10)
                num--;
            else num++;
        }
        for (j = 0; j < num - 15;)
            if (isStart(j)) {
                solve(j);
                j += 16;
            }
            else j++;
    }
    return 0;
}

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