-2
# include <iostream>
using namespace std;
int main ()
{
    int arr[100], num, sum=0, size=0;

    cout<<"Enter an integer: ";
    cin>>num;

    if (num < 0) num*=-1;

    while (num != -999 && size < 100)
    {
        arr[size]=num;
        size++;
        cin>>num;

        for (int j=1; j<size; j++)
        {
            for (int i=0; i<size-1; i++)
            {
                if (arr[i]>arr[i+1])
                {
                    int temp=arr[i];
                    arr[i]=arr[i+1];
                    arr[i+1]=temp;
                }
            }
        }

        int cont=1;
        for (int i=1; i<100; i++)
        {
            if (arr[i-1]=arr[i])
            {
                cout<<arr[i-1]<<"\t"<<cont<<endl;
                cont=1;
            }
            else
            {
                    cont++;
            }

            cout<<arr[i]<<cont<<endl;
        }
    }
    return 0;
}

it must take numbers from user and sorted them to incresing order, then cout them with number of reptiton times.
the output shoud be like that:-

Numbers     Count

13                    1
15                    2
28                    2
40                    1
48                    1
62                    3
65                    3
95                    4 

thanx,
buy :)

Edited by mike_2000_17: Fixed formatting

Votes + Comments
Aaah my eyes!! ->> [URL="http://www.daniweb.com/forums/misc-explaincode.html"][noparse][code] [/code] [/noparse][/URL] [i]tags![/i]
You like red? try some orange.
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by StuXYZ
0

First use code tags.

Second the answer is LOTS and LOTS: including but not limited to

(a) putting using namespace std; , don't mistype
cont and cout.

(b) not considering what would happen if you enter -999

(c) Not considering that that you might not want to see all 100 numbers if you have only put in 2.

(d) not considering that there is a different between (a=b) and (a==b)

(e) not paying attention to the WARNINGS that your compiler is giving or using an old compile when a modern compiler is a download away.

(f) Not considering that std::cout<<2<<3<<std::endl; gives output of 23 Sorry for the slightly annoyed tone but RED letters and no code tags is kind of asking for it. However, if you fix those problems then it will be ok. BUT using a bubble sort with a sorted list each time is algorithmic madness.

I have just looked, this is your EIGHTH POST!!! Clearly you are beyond the ability to understand the written word so I guess none of this will help. If you want anymore help then please use code tags.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.