a IX-a A27 lecții INFORMATICĂ | 12 lecții T.I.C.
Informatică
Lectia 00001   |   Lectia 00   |   Lectia 01   |   Lectia 02   |   Lectia 03   |   Lectia 04   |   Lectia 05   |   Lectia 06   |   Lectia 07   |   Lectia 08   |   Lectia 09   |   Lectia 10   |   Lectia 101   |   Lectia 102   |   Lectia 103   |   Lectia 11   |   Lectia 11_2   |   Lectia 12   |   Lectia 12_2   |   Lectia 12_3   |   Lectia 12_4   |   Lectia 12_5   |   Lectia 13   |   Lectia 14   |   Lectia 17
Lectia 18   |   Lectia 19
T.I.C.

Lectia 01   |   Lectia 02   |   Lectia 03   |   Lectia 04
Lectia 05   |   Lectia 06   |   Lectia 07   |   Lectia 08   |   Lectia 09
Lectia 10   |   Lectia 11   |   Lectia 12
a IX-a B0 lecții INFORMATICĂ | 0 lecții T.I.C.
a IX-a C0 lecții INFORMATICĂ | 11 lecții T.I.C.
T.I.C.
Lectia 01   |   Lectia 02   |   Lectia 03   |   Lectia 04
Lectia 05   |   Lectia 06   |   Lectia 07   |   Lectia 08
Lectia 10   |   Lectia 12   |   Lectia 13
a IX-a D0 lecții INFORMATICĂ | 0 lecții T.I.C.
a IX-a E0 lecții INFORMATICĂ | 0 lecții T.I.C.
a X-a A5 lecții INFORMATICĂ | 10 lecții T.I.C.
Opțional
Fișa 01   |   Fișa 02   |   Fișa 03   |   Fișa 04   |   Fișa 05
T.I.C.

Lectia 07   |   Lectia 08   |   Lectia 09   |   Lectia 10   |   Lectia 11   |   Lectia 12   |   Lectia 13   |   Lectia 14
Lecția 14_1
Lectia 15
a X-a B0 lecții INFORMATICĂ | 0 lecții T.I.C.
a X-a C0 lecții INFORMATICĂ | 0 lecții T.I.C.
a X-a D0 lecții INFORMATICĂ | 0 lecții T.I.C.
a XI-a A16 lecții INFORMATICĂ | 0 lecții T.I.C.
Informatică
Lectia 07   |   Lectia 08   |   Lectia 09   |   Lectia 10
Lectia 10 --- [ 2 Probleme rezolvate ]
1. Sa se scrie un program C++ care citeste o matrice de dimensiune n si m. Sa se interschimbe coloanele astfel incat elementele de pe prima linie sa fie in ordine descrescatoare.
Propune o soluție

S
o
l
u
ț
i
a:
Introdu următorul text: 494688460
#include <iostream>
using namespace std;
int x[50][50], n, m;
void citire(int x[50][50], int n, int m)
{
for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
{
cout<<"x["<<i<<"]["<<j<<"]=";
cin>>x[i][j];
}
}
void afisare(int x[50][50], int n, int m)
{
for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++)
cout<<x[i][j]<<" ";
cout<<endl;
}
}
void interschimba(int x[50][50], int n, int m, int c1, int c2)
{
    int aux;
        for(int j=1;j<=n;j++)
            {
                aux=x[j][c1];
                x[j][c1]=x[j][c2];
                x[j][c2]=aux;
            }
}
int main(){
cout<<"n=";
cin>>n;
cout<<"m=";
cin>>m;
citire(x,n, m);
afisare(x,n, m);
int ord=1;
while(ord)
{
ord=0;
for(int i=1;i<m;i++)
        if(x[1][i]<x[1][i+1])
        {
            interschimba(x, n, m, i, i+1);
            ord=1;
        }
}
cout<<"matricea dupa interschimbare este "<<endl;
afisare(x,n, m);
return 0;
}

2. Sa se scrie un program C++ care citeste o matrice de dimensiune n si m. Sa se interschimbe liniile matricei astfel incat elementele de pe ultima coloana sa fie in ordine crescatoare..
Propune o soluție

S
o
l
u
ț
i
a:
Introdu următorul text: 528697835
#include <iostream>
using namespace std;
int x[50][50], n, m;
void citire(int x[50][50], int n, int m)
{
for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
{
cout<<"x["<<i<<"]["<<j<<"]=";
cin>>x[i][j];
}
}
void afisare(int x[50][50], int n, int m)
{
for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++)
cout<<x[i][j]<<" ";
cout<<endl;
}
}
void interschimba(int x[50][50], int n, int m, int l1, int l2)
{
    int aux;
        for(int j=1;j<=m;j++)
            {
                aux=x[l1][j];
                x[l1][j]=x[l2][j];
                x[l2][j]=aux;
            }
}
int main(){
cout<<"n=";
cin>>n;
cout<<"m=";
cin>>m;
citire(x,n, m);
afisare(x,n, m);
int ord=1;
while(ord)
{
ord=0;
for(int i=1;i<n;i++)
        if(x[i][m]>x[i+1][m])
        {
            interschimba(x, n, m, i, i+1);
            ord=1;
        }
}
cout<<"matricea dupa interschimbare este "<<endl;
afisare(x,n, m);
return 0;
}


Fii primul care comentează lecţia
     Submit
  |   Lectia 11   |   Lectia 12   |   Lectia 13   |   Lectia 14
Lectia 16   |   Lectia 18   |   Lectia 19   |   Lectia 20   |   Lectia 21
Lectia 23   |   Lectia 24
Lectia 36
a XI-a B0 lecții INFORMATICĂ | 0 lecții T.I.C.
a XI-a C0 lecții INFORMATICĂ | 0 lecții T.I.C.
a XI-a D0 lecții INFORMATICĂ | 9 lecții T.I.C.
T.I.C.
Fişa 01   |   Fişa 02
Lectia 01   |   Lectia 02   |   Lectia 03   |   Lectia 04   |   Lectia 05   |   Lectia 06   |   Lectia 07
a XI-a E0 lecții INFORMATICĂ | 1 lecții T.I.C.
T.I.C.
Fişa 01
a XII-a A2 lecții INFORMATICĂ | 0 lecții T.I.C.
Informatică
Lectia 01   |   Lectia 02
a XII-a B0 lecții INFORMATICĂ | 0 lecții T.I.C.
a XII-a C0 lecții INFORMATICĂ | 0 lecții T.I.C.
a XII-a D0 lecții INFORMATICĂ | 0 lecții T.I.C.
a XII-a E0 lecții INFORMATICĂ | 0 lecții T.I.C.
Excelenta A0 lecții INFORMATICĂ | 0 lecții T.I.C.