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 |
为什么又WA了?#include <iostream> #include <string> using namespace std; char str[80]; int Scan() { int score,sum=0; bool flag; //先从左向右扫描: flag = 0; for (int i=0; i<strlen(str); i++) { if (str[i] == '/' && flag == 0){ flag = 1 ; score = 100; } else if (str[i] == '.'){ flag = 0; score = 100; } else if(str[i] == '|' && flag == 0) { flag = 1; score = 50; } else score = 0; sum += score; } //再从右向左扫描: flag = 0; for (--i; i>0; i--) { if (str[i] == '\\' && flag == 0){ flag = 1 ; score = 100; } else if (str[i] == '.'){ flag = 0; score = 0; }//note else if(str[i] == '|' && flag ==0){ flag = 1; score = 50; } else score = 0; sum += score; } return sum/strlen(str) ; } int main() { while(1) { gets(str); if ( str[0] == '#') break; cout << Scan() << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator