atcodet160a reverser and count
时间: 2024-02-02 10:04:43 浏览: 54
Sure, I'd be happy to help you with that problem!
The problem statement for ATC160A Reverser and Count is as follows:
You are given a 4-digit integer N. Write a program to reverse its digits and count the number of digits that are different from the original number.
For example, if N is 1234, you should output 4, since all digits are different from the original number and the reversed number is 4321.
To solve this problem, you can use the following steps:
1. Read in the integer N.
2. Convert N to a string so that you can easily reverse its digits.
3. Reverse the string representation of N.
4. Iterate through the original and reversed strings simultaneously and count the number of times the digits are different.
5. Output the count.
Here's some Python code that implements this algorithm:
```
n = input()
n_rev = n[::-1]
count = 0
for i in range(len(n)):
if n[i] != n_rev[i]:
count += 1
print(count)
```
I hope this helps! Let me know if you have any further questions.
阅读全文