#K1606. String to Integer Conversion
String to Integer Conversion
String to Integer Conversion
You are given a string S
that represents a non-negative integer. Your task is to convert this string into its corresponding integer without using any built-in conversion functions. In other words, you should manually process each digit and form the resulting number by performing arithmetic operations.
Note that the string may contain leading zeros. In such cases, the output should not display any redundant zeros. For example, the string "00789" should be converted to the integer 789. If the string represents zero (e.g. "0" or "0000"), simply output 0.
The conversion must be implemented by iterating over the string and using arithmetic to compute the result. Do not use any shortcuts or library functions that directly perform the conversion.
inputFormat
The input consists of a single line containing a string S
that is composed exclusively of digits (0-9). The string may include leading zeros.
outputFormat
Output the integer value represented by the string, with no leading zeros. If the string evaluates to zero, output 0
.
1234
1234