nicuvlad76

Untitled

Nov 25th, 2020
410
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>///fisiere
  2. using namespace std;
  3. ifstream fin("nrcurat.in");///de intrare
  4. ofstream fout("nrcurat.out");///de iesire
  5. int main()
  6. {
  7.    int n,c,ogl, cnt,i,nr,cn;
  8.    while(fin>>n) ///se citeste numar cu numar
  9.    {
  10.       ogl=0;  cnt=0; nr=0;
  11.       cn=n;
  12.       while(n!=0)
  13.       {
  14.           c=n%10;
  15.           n=n/10;
  16.           cnt++; ///numara cate cifre
  17.           ogl=ogl*10+c;///oglindit
  18.       }
  19.       ///cream numarul cu 9999..9
  20.       for(i=1;i<=cnt;i++)
  21.         nr=nr*10+9;
  22.  
  23.       if(ogl==nr-cn) fout<<1<<" ";
  24.       else fout<<0<<" ";
  25.    }
  26.     return 0;
  27. }
  28.  
RAW Paste Data