Click here to Skip to main content
14,365,441 members

C / C++ / MFC

 
GeneralRe: Problem using strings Pin
Rodrigo Lourenço8-Jun-19 1:00
memberRodrigo Lourenço8-Jun-19 1:00 
AnswerRe: Problem using strings Pin
Rodrigo Lourenço8-Jun-19 1:05
memberRodrigo Lourenço8-Jun-19 1:05 
GeneralRe: Problem using strings Pin
jschell8-Jun-19 5:36
memberjschell8-Jun-19 5:36 
GeneralRe: Problem using strings Pin
CPallini9-Jun-19 23:41
mveCPallini9-Jun-19 23:41 
JokeRe: Problem using strings Pin
Peter_in_278010-Jun-19 2:41
professionalPeter_in_278010-Jun-19 2:41 
GeneralRe: Problem using strings Pin
CPallini10-Jun-19 6:51
mveCPallini10-Jun-19 6:51 
GeneralRe: Problem using strings Pin
John R. Shaw11-Jun-19 18:47
memberJohn R. Shaw11-Jun-19 18:47 
QuestionProblem in binary search using C++ Pin
Member 144829306-Jun-19 0:01
memberMember 144829306-Jun-19 0:01 
I have copied a program from CrazyGeeks website and modified some of its statements. Anyone please tell me whats wrong in below code:
#include <iostream>
using namespace std;

int main()
{
int count, j, elements[50], search_num, first, last, mid;
cout<<"Enter the total number of elements :";
cin>>count;

cout<<"\nEnter ">>count>>" numbers:\n";
for (j=0; j<count; j++)
{
cin>>elements[j];
}

cout<<"\nWhich number that you want to search: ";
cin>>search_num;
first = 0;

last = count-1;
mid = (first+last)/2;

// binary search
while (first <= last)
{
if(elements[mid] > search_num){
first = mid + 1;
}

else if(elements[mid] == search_num){
cout<<search_num<<" found in array at "<<mid+1<<"\n";
break;
}
else {
last = mid - 1;
}

mid = (first + last)/2;
}

if(first > last){
cout<<search_num<<" Not found in an array";
}
return 0;
}


Code link
AnswerRe: Problem in binary search using C++ Pin
CPallini6-Jun-19 0:27
mveCPallini6-Jun-19 0:27 
GeneralRe: Problem in binary search using C++ Pin
Member 144829306-Jun-19 0:44
memberMember 144829306-Jun-19 0:44 
GeneralRe: Problem in binary search using C++ Pin
CPallini6-Jun-19 0:47
mveCPallini6-Jun-19 0:47 
AnswerRe: Problem in binary search using C++ Pin
Victor Nijegorodov6-Jun-19 8:20
memberVictor Nijegorodov6-Jun-19 8:20 
QuestionGlobal Event in C++ Pin
Member 142210415-Jun-19 22:29
memberMember 142210415-Jun-19 22:29 
AnswerRe: Global Event in C++ Pin
Stefan_Lang5-Jun-19 23:05
memberStefan_Lang5-Jun-19 23:05 
GeneralRe: Global Event in C++ Pin
Member 142210416-Jun-19 0:40
memberMember 142210416-Jun-19 0:40 
GeneralRe: Global Event in C++ Pin
Stefan_Lang6-Jun-19 22:28
memberStefan_Lang6-Jun-19 22:28 
GeneralRe: Global Event in C++ Pin
Member 142210417-Jun-19 0:15
memberMember 142210417-Jun-19 0:15 
AnswerRe: Global Event in C++ Pin
CPallini5-Jun-19 23:50
mveCPallini5-Jun-19 23:50 
GeneralRe: Global Event in C++ Pin
Member 142210416-Jun-19 0:45
memberMember 142210416-Jun-19 0:45 
GeneralRe: Global Event in C++ Pin
CPallini6-Jun-19 0:54
mveCPallini6-Jun-19 0:54 
GeneralRe: Global Event in C++ Pin
Member 142210416-Jun-19 0:58
memberMember 142210416-Jun-19 0:58 
GeneralRe: Global Event in C++ Pin
CPallini6-Jun-19 1:09
mveCPallini6-Jun-19 1:09 
GeneralRe: Global Event in C++ Pin
Stefan_Lang6-Jun-19 22:56
memberStefan_Lang6-Jun-19 22:56 
QuestionShellExecute open Pin
_Flaviu4-Jun-19 23:28
member_Flaviu4-Jun-19 23:28 
AnswerRe: ShellExecute open Pin
Richard MacCutchan5-Jun-19 0:01
protectorRichard MacCutchan5-Jun-19 0:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.