Jump to content

Ordonare crescator/descrescator sir numere C++

Recommended Posts

Sa se ordoneze crescator/descrescator un sir de n numere naturale. Cine ma poate ajuta sa gasesc gresela?

#include <iostream>
	#include <conio.h>
using namespace std;
int main()
	    int s[100], n, i, j, tmp = 0;
    cout << "Numarul de componente in vector sunt: "; cin >> n;
    for (i = 0; i < n; i++) {
        cout << "s[" << i << "]=";
        cin >> s;
    for (j = 1; j <= n; j++) {
        for (i = 0; i = n - 1; i++) {
            if (s > s[i + 1]) {
                tmp = s;
                s = s[i + 1];
                s[i + 1] = tmp;
	    for (i = 0; i < n; i++) {
        cout << s << endl;
    return 0;
Link to post
Share on other sites

Asta e tot? :O

Daca tot ai 2 INCLUDE, foloseste si la primul rand ( iostream.h )

Le vrei sortate folosind insertia sau prin numarare?

Tu trebuie a ai 3 parti, A, B, C, in genul: 

#include <iostream.h>

int a[25], b[25], c[25]

count << si aici numarul de elemente>>

Iar A, B, C trebuie duse in aceasi directie.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.