-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinding same number index.cpp
59 lines (46 loc) · 1.5 KB
/
finding same number index.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
using namespace std;
// This Program is Written By USMANTAHIR@UOGSKT2K17
int main()
{
int size, num ,count, a ,run = false,v ;
do{
cout << "Enter the size of Array: ";
cin >> size;
int array[size];
for (int i= 0; i< size ; i++){
cout << "Enter the data for array["<< i<< "] ";
cin >> array[i];
}
cout << "Enter the number you want to found in Array: ";
cin >> num;
count = 0;
for (int i= size-1; i>= 0 ; i--){
if(array[i]== num){
count++;
}
}
int index[count];
a =0;
for(int j=0; j< size; j++){
if(array[j]== num){
index[a]= j;
a++;
}
}
cout << "This Number is found on these indexes "<< endl;
for (int p = 0; p<count; p++){
cout <<"["<< index[p]<< "] ";
}
cout << endl;
cout << "################################################################"<< endl;
cout << "################################################################"<< endl;
cout << "******This Code is Written By USMANTAHIR@UOGSKT2K17(SEC B)******"<< endl;
cout << "################################################################"<< endl;
cout << "################################################################"<< endl;
cout <<endl<< "Want to Run Again? if yes Press '1' else press '0' to exit."<< endl;
cin >> v;
if(v == 1)run = true;
}while(run);
return 0;
}