s1--Enter 10 digits, remove duplicates, and then sort output

Source: Internet
Author: User
* * The copyright and version of the Declaration section:
*copyright (c) 2013, Yantai University computer College students
*all rights reserved.
* File name:
* Author: Shang
* Date of Completion: May 25, 2014
* version number: v0.1
* Description of task and solution:
* Input Description: No
* Problem Description: Input 10 digits from keyboard, Remove duplicates, then from small to large output.
* Program Input:
* Program output:
* Problem Analysis:
* Algorithm Design: * *
#include <iostream>
using namespace std;
int main ()
{
    int a[10],k=0,i,j;
    for (int i=0; i<10; ++i)
    {
        cin>>a[i];
    }
    For (i=0, i<10; ++i) for
        (j=0; j<9-i; ++j)
        {
            if (a[j]>a[j+1))
            {
                k=a[j];
                A[J]=A[J+1];
                A[j+1]=k
            }
        }
    For (i=0 i<10; ++i)
    {
        if (a[i]==a[i+1))
        {
            ++i;
        }
        cout<<a[i]<< "";
    }
    return 0;
}


Results show:

Experience: When the test, the program output error, did not remove duplicate numbers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.