Thread: Goodbye Duplicates! <-How to program?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    12

    Goodbye Duplicates! <-How to program?

    Write a program that will read in N numbers, each of which is between 1 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read.

    Specs:

    Use functions for the user inputs as well as displaying the output and array manipulation.
    Use c++ language.

    INPUT:
    The first lin of inputs is the number of inputs cases (N), which is a positive integer that does not exceed 100. the succeeding N lines specify the integers that the program reads.

    OUTPUT:
    Print out each unique element of thee array preceded by "#x - ", where x is the element number. Then, print out the elements with duplicates, in the order of their occurrence during input, separated by a space.

    This is my current code:
    Code:
    #include<iostream>
    #include<conio.h>
    #include<stdlib.h>
    
    using namespace std;
    
    int inputs(int);
    int numero[101];
    main()
    {
        int numbers;
        cin>>numbers;
        if (numbers>100 || numbers<1) { system("cls"); main(); }
        else { inputs(numbers);  }
        system("cls");
        main();
    }  
    int inputs(int numbers)
    {
         int a;
         for (int x=1; x<=numbers; x++)
        {
            cin>>numero[x];
            if (numero[x]==numero[x]) { a=numero[x]; }
            else if (numero[x]==numero[x]) { a=numero[x]; }
        }    
        cout<<"b "<<a;
    }
    Last edited by Salem; 12-14-2006 at 06:25 AM. Reason: Remove the YELLING

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  2. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM