[C++] Funcție sortare vector - Tutoriale si exercitii - GAMELIFE România Jump to content

Recommended Posts

Posted

//se  citesc  datele intr un vector  . Sa se tipareasca  sortat vectorul...

#include <iostream>
using namespace std;
void citesc(int vt[10], int n)
{
    int i;
    for(i=1; i<=n; i++)
    {cout<<"v["<<i<<"]= "; cin>>vt[i];}
}

void sortez(int vt[10], int n)
{
    int i,gasit,aux;
    do
    {
        gasit=0;
        for(i=1; i<=n-1; i++)

            if (vt[i]>vt[i+1])
            {
                aux=vt[i];vt[i]=vt[i+1];vt[i+1]=aux;
                gasit=1;
            }
    }while(gasit);

   // {cout<<"v["<<i<<"]= "; cin>>vt[i];}
}
void scriu(int vt[10], int n)
{
    int i;
    for(i=1; i<=n; i++)
    cout<<vt[i]<<endl;
}

int main(void)
{
int n, v[30];
cout<<"Dati dimensiunile vectorului \n";
cout<<"n = ";cin>>n;
citesc (v,n);
sortez(v,n);
scriu(v,n);
}

 

  • Like 2
  • 1 month later...
  • Administrators
Posted

aceasta e anulata nu trebuie neaparat sa o scrii :

 

 // {cout<<"v["<<i<<"]= "; cin>>vt[i];}
	

  • Like 2

Blog personal : https://www.facebook.com/jurnalulunuivisator/

Canal youtube : https://www.youtube.com/gabytzuspecial

Grup muzica : https://www.facebook.com/groups/muzica2025

 

FQ9snHC.gif

  • 5 months later...
  • Scripter
Posted

are un nume algoritmul de sortare sau nu?

  • Like 1

sizeof(Life) - 1

Segmentation fault (core dumped)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...

Important Information