Блог пользователя alt_438

Автор alt_438, история, 3 года назад, По-английски

Given a positive integer N and a digit D. The task is to find out the place value of a digit D in the given number N. If multiple occurrences of digit occur then find the maximum place value. please suggest how to solve this problem.

  • Проголосовать: нравится
  • -8
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Chup randi

»
2 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится
int main(){
  int n,d;
  scanf("%d%d",&n,&d);
  
  int rem,temp,answer = 0;
  temp = 1;
  while(1){
    rem = n%10;
    n = n/10;
   
    if(rem == d){
        answer = temp*rem;
        break;
    }
    temp *= 10;
  }
  printf("%d",answer);
}

I think the code is self understandable.