Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int n,d,NR,s,S1;
  5. float ma,S;
  6. int main(){
  7.      cin>>n;
  8.      for(d=1; d<=n; d++){  
  9.           if(n%d==0){       
  10.                s=s+d;      
  11.                NR++;   
  12.           }
  13.       }
  14.       ma=(float) s/NR;
  15.       if(ma==(int)ma)    cout<<ma<<".00";
  16.       else if(ma * 10 == int(ma * 10))    cout<<ma<<'0';
  17.       else{   
  18.           ma=ma*100;   
  19.           S1=(int)ma;   
  20.           S=( float) S1/100;   
  21.           cout <<S;
  22.       }
  23.       return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement