"Link" I am the link, point me:)
Test instructions
Enter the test instructions here
Exercises
Simulation is good.
Code
/*1.Shoud It use long long?2.Have ever test several sample (at least therr) yourself?3.Can You promise the solution are right? At Least,the main ideal4.use the puts ("") or Putchar () or printf and such things?5.init The used array or any value?6.use error max_value?7.use scanf instead of cin/cout?*/#include <bits/stdc++.h>using namespaceStdConst intN = -;intN, M, Q;intRest[n +Ten];p Air<vector <int, Vector <int> > V[n +Ten];map <int,int> Cnt[n+10];intMain () {#ifdef Local_defineFreopen ("F:\\C++source\\Rush_in.txt ","R", stdin); Freopen ("F:\\C++source\\Rush_out.txt ","W", stdout);#endifIos::sync_with_stdio (0), Cin.tie (0);intKase =0; while(CIN >> n && N) { for(inti =1; I <= N; i++) Cin >> Rest[i]; Cin >> m; for(inti =1; I <= m; i++) {v[i].first.clear (), v[i].second.clear (); Cnt[i].clear ();intX CIN >> X; while(X! =0) {if(X <0) {cnt[i][-x]++; V[i].first.push_back (-X); }Else{v[i].second.push_back (x); } cin >> X; }} cout <<"Case"<< ++kase <<": ";BOOLAlive =true; Cin >> Q; for(inti =1; I <= Q; i++) {BOOLOK =false; for(intj =1; J <= M; J + +) {BOOLOk1 =true; for(intX:v[j].first) {if(Rest[x] < cnt[j][x]) Ok1 =false; }if(OK1) { for(intX:v[j].first) {rest[x]--; } for(intX:v[j].second) {rest[x]++; } OK =true; Break; } }if(!ok) {alive = OK; cout <<"dead after"<< I-1<<"Transitions"<< Endl; Break; } }if(Alive) {cout <<"Still live after"<< Q <<"Transitions"<< Endl; } cout <<"Places with tokens:"; for(inti =1; I <= N; i++)if(Rest[i]) cout <<" "<< I <<" "<<"("<< Rest[i] <<")"; cout << Endl << Endl; }return 0;}
"Exercise 6-7 UVA-804" Petri Net Simulation