Advertisement
STANAANDREY

_9

Dec 16th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. /* a
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.  unsigned long n,E=0,nr,i=1,cif1,cif2;
  9.  
  10.  cin>>n;
  11.  
  12.  while (i<=n)
  13.  {
  14.      cif1=i;
  15.      cif2=i+1;
  16.      nr=cif1*10+cif2;
  17.    i++;
  18.      E+=nr;
  19.  }
  20.  
  21.  cout<<E;
  22.  
  23.    return 0;
  24. }
  25. //*/
  26. /// e=12+23+34+....+nr(n(n+1))
  27.  
  28.  
  29. /* b
  30. #include <iostream>
  31. using namespace std;
  32.  
  33. int main()
  34. {
  35.  
  36.  unsigned long n,E=0,nr=0,i=1,nrant=0;
  37.  
  38.  cin>>n;
  39.  
  40.    while (i<=n)
  41.    {
  42.  
  43.        nr=nr*10+i;  
  44.  
  45.        E+=nr;          
  46.  
  47.        if (nr==0)    
  48.         nr=1;
  49.                                      
  50.         i++;          
  51.  
  52.    }
  53.  cout<<E;
  54.  
  55.    return 0;
  56. }
  57. //*/
  58. /// e=1+12+123+1234+...nr(1234...n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement