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 |
纪念一下,数组越界 的bug 查的很辛苦啊 ,谨以此铭记!!!题目不难,但是离做对还有很大差距,勉励! // Prob_1056.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <vector> using namespace std; bool visit_end_array[2048];//<----用1026死的很惨 int main(void) { char s[16]; vector<bool> decodeablearray; bool decodeable = true; while(cin>>s) { if (s[0]=='9') { decodeablearray.push_back(decodeable); decodeable = true; memset(visit_end_array,0,sizeof(visit_end_array)); } else { if(decodeable) { int index = 1; for (int i=0;s[i]!='\0';i++) { if (s[i]=='0') { index = index <<1; } else { index = (index<<1)+1; } if(visit_end_array[index]) { decodeable = false; break; } } if (decodeable) { visit_end_array[index]=true; } } } } for (int j=0;j<decodeablearray.size();j++) { cout<<"Set "<<j+1<<" is ";//<--此处曾经忘记加1了 if (!decodeablearray[j]) { cout<<"not "; } cout <<"immediately decodable"<<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