Click here to Skip to main content
14,332,022 members

C / C++ / MFC

 
GeneralRe: Problem using strings Pin
Rodrigo Lourenço8-Jun-19 0:00
memberRodrigo Lourenço8-Jun-19 0:00 
AnswerRe: Problem using strings Pin
Rodrigo Lourenço8-Jun-19 0:05
memberRodrigo Lourenço8-Jun-19 0:05 
GeneralRe: Problem using strings Pin
jschell8-Jun-19 4:36
memberjschell8-Jun-19 4:36 
GeneralRe: Problem using strings Pin
CPallini9-Jun-19 22:41
mveCPallini9-Jun-19 22:41 
JokeRe: Problem using strings Pin
Peter_in_278010-Jun-19 1:41
professionalPeter_in_278010-Jun-19 1:41 
GeneralRe: Problem using strings Pin
CPallini10-Jun-19 5:51
mveCPallini10-Jun-19 5:51 
GeneralRe: Problem using strings Pin
John R. Shaw11-Jun-19 17:47
memberJohn R. Shaw11-Jun-19 17:47 
QuestionProblem in binary search using C++ Pin
Member 144829305-Jun-19 23:01
memberMember 144829305-Jun-19 23: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
CPallini5-Jun-19 23:27
mveCPallini5-Jun-19 23:27 
GeneralRe: Problem in binary search using C++ Pin
Member 144829305-Jun-19 23:44
memberMember 144829305-Jun-19 23:44 
GeneralRe: Problem in binary search using C++ Pin
CPallini5-Jun-19 23:47
mveCPallini5-Jun-19 23:47 
AnswerRe: Problem in binary search using C++ Pin
Victor Nijegorodov6-Jun-19 7:20
memberVictor Nijegorodov6-Jun-19 7:20 
QuestionGlobal Event in C++ Pin
Member 142210415-Jun-19 21:29
memberMember 142210415-Jun-19 21:29 
AnswerRe: Global Event in C++ Pin
Stefan_Lang5-Jun-19 22:05
memberStefan_Lang5-Jun-19 22:05 
GeneralRe: Global Event in C++ Pin
Member 142210415-Jun-19 23:40
memberMember 142210415-Jun-19 23:40 
GeneralRe: Global Event in C++ Pin
Stefan_Lang6-Jun-19 21:28
memberStefan_Lang6-Jun-19 21:28 
GeneralRe: Global Event in C++ Pin
Member 142210416-Jun-19 23:15
memberMember 142210416-Jun-19 23:15 
AnswerRe: Global Event in C++ Pin
CPallini5-Jun-19 22:50
mveCPallini5-Jun-19 22:50 
GeneralRe: Global Event in C++ Pin
Member 142210415-Jun-19 23:45
memberMember 142210415-Jun-19 23:45 
GeneralRe: Global Event in C++ Pin
CPallini5-Jun-19 23:54
mveCPallini5-Jun-19 23:54 
GeneralRe: Global Event in C++ Pin
Member 142210415-Jun-19 23:58
memberMember 142210415-Jun-19 23:58 
GeneralRe: Global Event in C++ Pin
CPallini6-Jun-19 0:09
mveCPallini6-Jun-19 0:09 
GeneralRe: Global Event in C++ Pin
Stefan_Lang6-Jun-19 21:56
memberStefan_Lang6-Jun-19 21:56 
QuestionShellExecute open Pin
_Flaviu4-Jun-19 22:28
member_Flaviu4-Jun-19 22:28 
AnswerRe: ShellExecute open Pin
Richard MacCutchan4-Jun-19 23:01
protectorRichard MacCutchan4-Jun-19 23: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.