🟢 Վարժություն 10

Գրել ծրագիր, որն էկրանին տպում է տրված ոչ բացասական ամբողջ թվի թվանշանները հակառակ կարգով և անջատված բացատով։

Օրինակներ՝

Մուտք - 123։ Ելք - 3 2 1

Մուտք - 1000։ Ելք - 0 0 0 1



#include <iostream>
int main() {
	int n;
  std::cin >> n;
  //Put your code here
}
Հուշում 1

Աշխատեցրե՛ք այս ծրագիրը և ուսումնասիրեք արդյունքը։

#include <iostream>
int main() {
	int n;
  std::cin >> n;
  while(n != 0) {
    n = n / 10;
    std::cout << n; 
  }
}
Հուշում 2

Ի՞նչ է պետք գրել ?-ի փոխարեն, որպեսզի կատարվի խնդրի պահանջը։

#include <iostream>
int main() {
	int n;
  std::cin >> n;
  /* Մշակել n == 0 դեպքը */
  while(n != 0) {
    int digit = / * ? */;
    std::cout << digit << " ";
    n = n / 10;
  }
}

Constraints

Time limit: 0.2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue