Advertisement
ChaeYuriya

Week 7 : main.cpp

Nov 3rd, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include "stack_character.cpp"
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     stack S1, S2, S3;
  8.     infotype xpop;
  9.     createStack(S1);
  10.     printInfo(S1);
  11.     push(S1, 'E');
  12.     printInfo(S1);
  13.     push(S1, 'T');
  14.     printInfo(S1);
  15.     push(S1, 'U');
  16.     printInfo(S1);
  17.     pop(S1, xpop);
  18.     printInfo(S1);
  19.     cout << endl << "Data diurutkan ascending:" << endl;
  20.     ascending(S1);
  21.     printInfo(S1);
  22.     cout << endl << "Data diurutkan descending:" << endl;
  23.     descending(S1);
  24.     printInfo(S1);
  25.     createStack(S2);
  26.     string kalimat = "Hai kamu!!!";
  27.     cout <<endl<< "\'Hai kamu!!!\' di dalam stack:" <<endl;
  28.     stringToStack(S2,kalimat);
  29.     printInfo(S2);
  30.     cout << endl << "Data diurutkan ascending:" << endl;
  31.     ascending(S2);
  32.     printInfo(S2);
  33.     cout << endl << "Data diurutkan descending:" << endl;
  34.     descending(S2);
  35.     printInfo(S2);
  36.      createStack(S3);
  37.     cout <<endl<< "Membalik urutan elemen " <<endl;
  38.     string input;
  39.     cout << "Masukkan string: ";
  40.     // Inputkan “IFLAB 2024/2025”
  41.      getline(cin, input); // Menggunakan getline untuk membaca string dengan spasi
  42.      stringToStack(S3, input);
  43.     cout << endl << "Data sebelum dibalik:";
  44.     printInfo(S3);
  45.     cout << endl;
  46.      reverseStack(S3);
  47.     cout << "Data setelah dibalik:";
  48.     printInfo(S3);
  49.     cout << endl;
  50.     return 0;
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement