Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- //pravi problem koga second digit==0
- int main (){
- int number, copynumber, copynumber2;
- int last_digit, secondtolast_digit;
- int flag;
- while(scanf("%d", &number)){
- if(number<=10){
- continue;
- }
- else{
- int temp=number;
- copynumber=0;
- int coef=1;
- int lastdigittemp, secondtolastdigittemp;
- lastdigittemp=temp%10;
- secondtolastdigittemp=temp%100/10;
- if(lastdigittemp < secondtolastdigittemp){
- flag=2;
- }
- if(lastdigittemp > secondtolastdigittemp){
- flag=1;
- }
- while(temp!=0){
- last_digit=temp%10;
- secondtolast_digit=temp%100/10;
- if(flag==3){
- copynumber+=temp*coef;
- coef=coef*100;
- }
- if(flag==2){
- if(last_digit<5 && secondtolast_digit>=5){
- copynumber+=(secondtolast_digit*10+last_digit)*coef;
- coef=coef*100;
- }
- }
- if(flag==1){
- if(last_digit>=5 && secondtolast_digit<5){
- copynumber+=(secondtolast_digit*10+last_digit)*coef;
- coef=coef*100;
- }
- }
- temp/=100;
- if( log10( (double)temp ) >=0 && log10( (double)temp ) <= 1 ){
- flag = 3;
- }
- }
- if(copynumber==number){
- printf("%d\n", copynumber);
- }
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment