הערה (קובץ קוד)
קובץ זה הוא קובץ קוד מסוג C.
#include <stdbool.h>
#include <stdio.h>
int main(void)
{
int userInput;
if (scanf("%d", &userInput) > 0)
{
if (userInput < 0)
{
printf("-");
userInput = -userInput;
}
bool beforeDigit = true;
while (userInput > 0)
{
int currentDigit = (userInput % 10);
if (beforeDigit && currentDigit != 0)
{
beforeDigit = false;
}
if (!beforeDigit || currentDigit != 0)
{
printf("%d", currentDigit);
}
userInput /= 10;
}
printf("\n");
}
else
{
printf("Error in input!\n");
}
return 0;
}