Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
其实这题并不难,但要注意几种情况(附代码)#include <iostream> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <string> #include <cstdio> #include <climits> using namespace std; char data[120]; int main() { while (true) { scanf("%s", data); if (data[0] == '#') break; int len = strlen(data); double sum = 0; for (int i=0; i < len; i++) { if (data[i] == '.') sum += 100; else if (data[i] == '_') continue; else if (data[i] == '/') { if (i == 0) sum += 100; for (int j=i-1; j >=0; j--) { if (data[j] == '.') { sum += 100; break; } else if (data[j] == '|' || data[j] == '\\') break; else if (j == 0) sum += 100; } } else if (data[i] == '\\') { if (i == len-1) sum += 100; for (int j=i+1; j < len; j++) { if (data[j] == '.') { sum += 100; break; } else if (data[j] == '|' || data[j] == '/') break; else if (j == len-1) sum += 100; } } else if (data[i] == '|') { if (i == 0 ) sum += 50; if (i == len - 1) sum += 50; for (int j=i-1; j >=0; j--) { if (data[j] == '.') { sum += 50; break; } else if (data[j] == '|' || data[j] == '\\') break; else if (j == 0) sum += 50; } for (int j=i+1; j < len; j++) { if (data[j] == '.') { sum += 50; break; } else if (data[j] == '|' || data[j] == '/') break; else if (j == len-1) sum += 50; } } } sum /= len; printf("%d\n", (int)sum); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator