Advertisement
Guest User

std::program

a guest
Apr 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string.h>
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int pil;
  11. char key [10];
  12. char s [10][10] = {"Budi", "Wawan", "Tri Wahju","Zidane", "Alif", "Sultan"};
  13. char daftar [25][25];
  14. int i;
  15. int limit;
  16. std::cout<<"Menu Pilihan = "<<endl;
  17. std::cout<<"1. Searching Nama"<<endl;
  18. std::cout<<"2. Sortir Angka"<<endl;
  19. std::cout<<"3. Searching Angka"<<endl;
  20. std::cout<<" "<<endl;
  21. std::cout<<"Pilih salah satu dari tiga menu!"<<endl;
  22. std::cout<<" "<<endl;
  23. std::cout<<"Pilihan Anda: ";
  24. std::cin>>pil;
  25.  
  26. system("cls");
  27.  
  28. if (pil==1)
  29. {
  30. std::cout<<"Mencari nama : ";
  31. std::cin>>key;
  32.  
  33.  
  34. for (i=0; i<=0; i++)
  35. {
  36. if (strcmp ( s[i] , key) == 0)
  37. {
  38. std::cout<<"Nama "<<key<<" ditemukan"<<endl;
  39. }
  40. else
  41. {
  42. std::cout<<"Nama "<<key<< " tidak ditemukan"<<endl;
  43. }
  44. }
  45. }
  46.  
  47. else if (pil==2)
  48. {
  49. int arr[3];
  50. int n = sizeof(arr)/sizeof(arr[3]);
  51.  
  52. sort(arr, arr+n);
  53.  
  54. std::cout<<"Masukkan banyak angka (Maximum 3) = ";
  55. std::cin>>limit;
  56.  
  57. system("cls");
  58.  
  59. for (int x=0; x <= limit; x++)
  60. {
  61. std::cout<<"Angka ke-"<<x<<" = ";
  62. std::cin>>daftar[x];
  63. }
  64.  
  65. for (i=0; i<=n; i++)
  66. {
  67. std::cout<<arr[i]<<" ";
  68. }
  69. }
  70.  
  71. else if (pil==3)
  72. {
  73. std::cout<<"Masukkan banyak angka (Maximum 6) = ";
  74. std::cin>>limit;
  75.  
  76. system("cls");
  77.  
  78. for (int x=0; x <= limit; x++)
  79. {
  80. std::cout<<"Angka ke-"<<x<<" = ";
  81. std::cin>>daftar[x];
  82. }
  83.  
  84. system("cls");
  85.  
  86. std::cout<<"Cari data : ";
  87. std::cin>>key;
  88.  
  89. system("cls");
  90.  
  91.  
  92. for (i=0; i<=0; i++)
  93. {
  94. if (strcmp ( s[i] , key) == 0)
  95. {
  96. std::cout<<"Angka "<<key<<" ditemukan"<<endl;
  97. }
  98. else
  99. {
  100. std::cout<<"Angka "<<key<< " tidak ditemukan"<<endl;
  101. }
  102. }
  103. }
  104.  
  105. return 0;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement