Guest User

04. Credit System

a guest
May 3rd, 2018
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3. unsigned long long int krediti[11];
  4. double getKr[11];
  5. unsigned long long int ocenka[11];
  6. using namespace std;
  7. int main() {
  8. int n;string s; cin>>n;
  9. double sum=0.0;
  10. int ocenki=0.0;
  11. for(int i=0;i<n;i++) {
  12.   cin>>s;
  13.   for(int j=0;j<=s.size()-2;j++)
  14.   {
  15.     krediti[i]*=10; krediti[i]+=(int)s[j]-48;
  16.   }
  17.   ocenka[i]=(int)(s[s.size()-1]-48);
  18. }
  19. for(int i=0;i<n;i++) {
  20.   if(ocenka[i]==2) getKr[i]=0;
  21.   if(ocenka[i]==3) getKr[i]=(double)(krediti[i]/2);
  22.   if(ocenka[i]==4) getKr[i]=(double)(krediti[i]*(70.0/100.0));
  23.   if(ocenka[i]==5) getKr[i]=(double)(krediti[i]*(85.0/100.0));
  24.   if(ocenka[i]==6) getKr[i]=(double)(krediti[i]);
  25.   sum+=getKr[i];
  26.   ocenki+=ocenka[i];
  27. }
  28. cout<<fixed<<setprecision(2)<<sum;
  29. cout<<endl<<fixed<<setprecision(2)<<(double)ocenki/n;
  30. cout<<endl;
  31.   return false;
  32. }
RAW Paste Data