fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // Introduc variabilele a, b, c şi x;
  6. int a, b, c, x;
  7. // Citesc a, b, c, x;
  8. cin >> a >> b >> c >> x;
  9. int x_copy;
  10. if (c != x % 10) cout << "NU";
  11. if (c == x % 10) { // verificam "c"
  12. // Introduc variabila “cnt” sa numar cifrele;
  13. int cnt = 0;
  14. // parcurg x;
  15.  
  16. while (x > 0) {
  17. ++cnt;
  18. x_copy = x; // identific "b" introducand o variabila copie a lui x
  19. //pentru a mentine penultima valoare a lui x
  20. x /= 10;
  21. }
  22. if (b == x_copy) {
  23. if (a == cnt)
  24. // verificam a si b
  25. cout << "DA";
  26. }
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 5316KB
stdin
3 1 2 102
stdout
DA