UVa 10188 Automated Judge Script

这题我做了4个多小时,太囧了。

/* File: 10188.cpp Author: ACboy Date: 2010-3-30 Result: AC Descripition: UVa 10188 Automated Judge Script */ #include <iostream> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> using namespace std; char str1[110][122]; char str2[110][122]; char digit1[12200]; char digit2[12200]; int n, m; int min(int a, int b) { return a < b ? a : b; } void get_digit() { memset(digit1, 0, sizeof(digit1)); memset(digit2, 0, sizeof(digit2)); int i, j; int len; int c; c = 0; for (i = 0; i < n; i++) { len = strlen(str1[i]); for (j = 0; j < len; j++) if (isdigit(str1[i][j])) { digit1[c++] = str1[i][j]; } } digit1[c] = '/0'; c = 0; for (i = 0; i < m; i++) { len = strlen(str2[i]); for (j = 0; j < len; j++) if (isdigit(str2[i][j])) { digit2[c++] = str2[i][j]; } } digit2[c] = '/0'; } int get_result() { int i, flag = 0; if (n != m) { flag = 2; } int Min = min(n, m); for (i = 0; i < Min; i++) { if (strcmp(str1[i], str2[i]) != 0 || flag == 2) { flag = 2; get_digit(); if (strcmp(digit1, digit2) != 0) { flag = 1; } break; } } return flag; } int main() { int count = 0; #ifndef ONLINE_JUDGE freopen("10188.txt", "r", stdin); #endif while (scanf("%d", &n) != EOF) { getchar(); if (n == 0) break; int i; memset(str1, 0, sizeof(str1)); memset(str2, 0, sizeof(str2)); for (i = 0; i < n; i++) { gets(str1[i]); } scanf("%d", &m); getchar(); for (i = 0; i < m; i++) { gets(str2[i]); } int result = get_result(); if (result == 1) { cout << "Run #" << ++count << ": Wrong Answer" << endl; } else if (result == 2) { cout << "Run #" << ++count << ": Presentation Error" << endl; } else { cout << "Run #" << ++count << ": Accepted" << endl; } } return 0; }

你可能感兴趣的:(c,File,2010)