ZasieuN

KUIS G

Feb 13th, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int cari(int a, int b[]){
  4. int j=0, index[10];
  5. for (int i=0;i<10;i++){
  6. if(b[i]==a){
  7. index[j]=i;
  8. j++;
  9. }
  10. }
  11. if (j>0){
  12. cout << a <<" ditemukan di index ke ";
  13. for(int i=0;i<j;i++){
  14. cout << index[i];
  15. }
  16. cout << "\n";
  17. }else{
  18. cout << a <<" tidak ditemukan"<<endl;
  19. }
  20. return 0;
  21. }
  22. int main(){
  23. int a;
  24. int data[] = {10, 12, 1, 83, 89, 23, 5, 24, 14, 19};
  25. cin >> a;
  26. cari(a, data);
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment