Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <string>
  5. using namespace std;
  6.  
  7. struct generale {
  8.  
  9. int ID;
  10. int tempo;
  11. };
  12.  
  13. struct speciale {
  14.  
  15. int ID;
  16. int tempo;
  17. speciale* pun;
  18. /*
  19. speciale () {
  20. pun = NULL;
  21. }
  22. */
  23. };
  24.  
  25.  
  26.  
  27. int main (){
  28.  
  29. int K, N, C;
  30. cin >> K;
  31. cin >> N;
  32. cin >> C;
  33.  
  34. vector<generale> myVector;
  35. vector<speciale*> myVector2;
  36.  
  37. for (unsigned int i = 0; i < C; ++i) {
  38. speciale* testa = NULL;
  39. myVector2.push_back(testa);
  40. }
  41. for (unsigned int i = 0; i < N; ++i) {
  42. int id, t;
  43. cin >> id;
  44. cin >> t;
  45. generale g;
  46. g.ID = id;
  47. g.tempo = t;
  48. myVector.push_back(g);
  49.  
  50. char val;
  51. char str = ';';
  52. for (cin >> val; val != str; cin >> val) {
  53. int indice = val - '0';
  54. speciale* s;
  55. s -> ID = id;
  56. s -> tempo = t;
  57. s -> pun = myVector2[indice];
  58. myVector2[indice] = s;
  59. }
  60. }
  61.  
  62. for (unsigned int i = 0; i < myVector.size(); ++i)
  63. cout << myVector[i].ID << " " << myVector[i].tempo << endl;
  64.  
  65. for (unsigned int i = 0; i < C; ++i){
  66. speciale* p = myVector2[i];
  67. while(p != NULL){
  68. cout << p -> ID << " " << p -> tempo << endl;
  69. p = p -> pun;
  70. }
  71. }
  72.  
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement