TOC666

שאלה 2

Feb 23rd, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. void ex2()
  2. {
  3. int arr[N1] = {1,1,2,2,1,2,3,1,2,4,2,2};
  4. int i,j,max=0,flag=0,count=0,big=0;
  5. for (i=0;i<N1;i++)
  6. {
  7. count = 0;
  8. if (arr[i] != flag)
  9. {
  10. flag = arr[i];
  11. for (j=0;j<N1;j++)
  12. if (arr[j] == flag)
  13. {
  14. count++;
  15. }
  16. if (count > max)
  17. {
  18. max = count;
  19. big = flag;
  20. }
  21. }
  22. }
  23. cout<<"The Element "<<big<<" was found "<<max<<" times"<<endl;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment