Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * Solution to homework assignment 1
- * Introduction to programming course
- * Faculty of Mathematics and Informatics of Sofia University
- * Winter semester 2021/2022
- *
- * @author Monika Dobrinova
- * @idnumber 8MI0600008
- * @task 5
- * @compiler VC
- *
- */
- #include <iostream>
- using namespace std;
- int main()
- {
- long long int n;
- cin >> n;
- long long int temp = n;
- int count = 0;
- while (temp)
- {
- temp /= 10;
- count++;
- }
- long long int pow = 1, num = 0;
- for (int i = 1; i < count; i++)
- {
- pow *= 10;
- }
- short int counter2=0;
- while (n)
- {
- num = n / pow;
- if (num % 2 != 0)
- {
- cout << num << " ";
- }
- else
- {
- counter2++;
- }
- n %= pow;
- pow /= 10;
- }
- if (count == counter2)
- {
- cout << "0";
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment