Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int a;
- int mainFlag = 0;
- while (scanf("%d", &a)) {
- if (a<10) {
- continue;
- }
- int flag = 1;
- int temp = a;
- int digit = (temp / 10) % 10;
- int lastDigit = temp % 10;
- int checkGreater;
- if (digit >= 5) {
- checkGreater = 1;
- } else if(digit < 5) {
- checkGreater = 0; }
- temp /= 10;
- while (temp>0) {
- digit = temp % 10;
- // printf("LAST DIGIT: %d\n", lastDigit);
- // printf("CURR DIGIT: %d\n", digit);
- // printf("CHECK FOR GREATER: %d\n", checkGreater);
- if (checkGreater) {
- if (digit < 5) {
- flag = 0; }
- checkGreater = 0;
- } else {
- if (digit >= 5) {
- flag = 0; }
- checkGreater = 1; }
- temp /= 10; }
- if (flag) {
- printf("%d\n", a); }}
- return 0;
- }
Add Comment
Please, Sign In to add comment