Advertisement
Istanvir389

2's Compliments

Oct 18th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int i,j;
  5.     char ibr[40];
  6.     gets(ibr);
  7.     int l=strlen(ibr);
  8.  for(i=l-1 ; i>=0; i--)
  9.  {
  10.      if(ibr[i]=='1')
  11.         break;
  12.  }
  13.    for(j=i-1; j>=0 ; j--)
  14.    {
  15.        if(ibr[j]=='1')
  16.         ibr[j]='0';
  17.      else
  18.             ibr[j]='1';
  19.    }
  20.    printf("%s",ibr);
  21.    return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement