Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string.h>
- #include <ctype.h>
- using namespace std;
- struct echipa
- {
- char nume[50];
- int rezultat;
- };
- struct echipa c[3];
- int main()
- {
- for (int i = 0; i < 3; i++) {
- cout << "Introduceti numele: ";
- cin.ignore();
- cin.getline(c[i].nume, 50);
- cout << "Introduceti rezultat: ";
- cin >> c[i].rezultat;
- }
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 2; j++) {
- if (c[j].rezultat < c[j + 1].rezultat) {
- struct echipa aux = c[j];
- c[j] = c[j + 1];
- c[j + 1] = aux;
- }
- }
- }
- for (int i = 0; i < 3; i++) {
- cout << c[i].nume << " ";
- }
- // Exemplu sortare vector/array cu numere int numere[10] = {14,3,5,6,7}
- /*
- for (int i = 0; i < 5; i++) {
- for (int j = 0; j < 5 - 1;j++) {
- if (numere[j] < numere[j + 1]) {
- int aux = numere[j];
- numere[j] = numere[j + 1];
- numere[j + 1] = aux;
- }
- }
- } */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement