Rezolvare BAC Informatica 2009 – Varianta 74 – Subiectul al III-lea problema 4
Mai jos puteti gasi rezolvarea problemei 4 de la subiectul III din varianta 74 pentru examenul de bacalaureat din anul 2009
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
int main() { | |
ifstream f("NUMERE.IN"); | |
int n,frecv[10],a,i; | |
f>>n; | |
for (i = 0; i < 10; i++) | |
frecv[i] = 0; | |
for (i = 0; i < n; i++) { | |
f>>a; | |
frecv[a]++; | |
} | |
int pusZero = 0; | |
for (i = 1; i < 10; i++) | |
while (frecv[i] != 0) { | |
cout<<i; | |
if (pusZero == 0) { | |
while (frecv[0] != 0) { | |
cout<<0; | |
frecv[0]--; | |
} | |
pusZero = 1; | |
} | |
frecv[i]--; | |
} | |
return 0; | |
} |
Spor la lucru! Daca aveti intrebari nu ezitati sa le lasati in comentarii, va vom raspunde cat de repede putem