1 Replies - 456 Views - Last Post: 10 June 2014 - 08:06 PM Rate Topic: -----

#1 Newbie-Programer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-June 14

I want add output from this program like data statistics.

Posted 10 June 2014 - 07:38 PM

I want add output from this program like data statistics.
example:
numbers that come out one time: 'number'
numbers that come out two time: 'number'
and so on
what can I do???

#include <iostream>
#include <ctime>
#include <cstdlib>
#define Number 100

using namespace std;

struct node{
	int frekuensi;
	node *next;
};

int main()
{
	int input;
	int i;
	int a;
	int temp;
	node *n;
	n = new node;

	cout<<" Input  : ";
	cin>>input;

	int c[input];


	srand(time(NULL));

	cout<<"Before sorting"<<endl;
	for(int i=0; i<input; i++)
	{
		c[i]= rand() % Number;
		cout<<c[i]<<" ";
	}
	cout<<endl;

	int size_array = sizeof(c)/sizeof(*c);

	cout<<"After sorting"<<endl;

	for(i=size_array-1;i>=0;i--)
    {
		for(a=0;a<=i;a++)
		{
			if(c[a]>c[a+1])
			{
				temp= c[a];
				c[a]= c[a+1];
				c[a+1]= temp;
			}
		}
	}

	for(a=0;a<=size_array-1;a++)
    {
        n = new node;
        n->frekuensi = 1;
        if(c[a]== c[a+1])
        {
            n->frekuensi += 1;
            cout<<c[a]<<"("<< n->frekuensi<<") ";
            a= a+n->frekuensi-1;
        }
        else
            cout<< c[a]<<" ";
    }
}

This post has been edited by modi123_1: 10 June 2014 - 08:06 PM
Reason for edit:: please use the code tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: I want add output from this program like data statistics.

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13947
  • View blog
  • Posts: 55,683
  • Joined: 12-June 08

Re: I want add output from this program like data statistics.

Posted 10 June 2014 - 08:06 PM

What is it doing now in comparison to what you want it to do?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1