hi please I need help
how to sort int line by line & get number of int in each line
I have Input
4 2 32 8 6
10 7 9 21 2 3
14 1 5

Output must be
2 4 6 8 32 count = 5
2 3 7 9 10 21 count = 6
1 5 14 count = 3

If you use vector<int> then you can use std::sort() to sort the numbers.

start of loop
    read a line
    split line into individual integers and put into vector
    call std::sort
    display values
end of loop

you can do the same with simple int array instead of vector, but then you would have to write you own sort algorithm.

commented: can you give me a code to do this +0

There are two things going on here - sorting the input in ascending order, and then counting the number of integers in a line.

So first off, you need a sorting algorithm to sort each line in ascending order. There are various sorting algorithms that you could use which you might want to Google. The easiest sort is the bubble sort, but this is the least efficient of the algorithms.

It may be easier to count the number of integers on each line first, then do the sorting.

Can any one write a code please>>>
I am beginner

No.

We were all beginners at one time. The only way for you to learn is by coding it yourself, making mistakes, and learning how to correct your mistakes. There is a lot of self-satisfaction in knowing that you can accomplish something.

Thank you <<<<<<<<<Ancient Dragon>>>>>>>>>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.