Advertisement
Sammy24

Untitled

Mar 14th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <fstream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("cifre.in");
  7. ofstream fout("cifre.out");
  8.  
  9. int aprinse[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  10. int v[10] = {1, 5, 1, 2, 2, 3, 1, 2, 0, 0};
  11.  
  12. int main()
  13. {
  14. int cerinta, nr;
  15.  
  16. fin >> cerinta >> nr;
  17.  
  18.  
  19. if(cerinta == 1)
  20. {
  21. int cnr = nr, apr = 0;
  22.  
  23. while(cnr)
  24. {
  25. apr += aprinse[cnr % 10];
  26. cnr /= 10;
  27. }
  28.  
  29. fout << apr;
  30. }
  31. else if(cerinta == 2)
  32. {
  33. int nrmari = 0, produs = 1;
  34.  
  35. while(nr)
  36. {
  37. nrmari += v[nr % 10];
  38. produs *= nrmari;
  39. nr /= 10;
  40. }
  41.  
  42. nrmari += produs;
  43.  
  44. fout << nrmari;
  45. }
  46.  
  47. fin.close();
  48. fout.close();
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement