Hi! I need help with the find function! I do not know how to use it in finding numbers.

For instance:
1 1 1 1 2 3 4 4 5 5 6 6 6 7 7 7 7

Using the find function, it will count the number of times a number appears.

1: 4 times
2: 1 time
3: 1 time
4: 2 times
5: 2 times
6: 3 times
7: 4 times

I need help with this, please! Thanks :D

Post some of your code.We could help out then. :D

yeah .. this my assignment in the past .. try it .. it work fine .. ;)

#include <iostream.h>
#include <stdlib.h>
main()
{ 
 //
 int array[10]={1,2,3,4,5,6,7,8,9,10};
 int left=0,right=9,middle;
 int number,i;
 bool sw=false;
 //
 cout<<"ARRAY: ";
 for (i=0;i<=9;i++)
 {
  cout<<array[i]<<";";
 } 
 cout<<" \n"<<"Number to find: ";
 cin>>number;
 while (sw == false && left <= right)
 { 
  middle=(left+right)/2; 
  if (number == array[middle]) 
  {
   sw=true;
   cout<<"number found.\n";
  }
  else
  {
   if (number < array[middle]) right=middle-1;
   if (number > array[middle]) left=middle+1;
  }
 }
 if (sw == false) cout<<"number not found.\n";
 system("Pause");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.