Advertisement
mbah_bejo

Kuartil genap

Jan 24th, 2021
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. int main (){
  6.     double arr[100];
  7.     int jumlah = 0;
  8.     int posisi;
  9.  
  10.     while (1)
  11.     {  
  12.         if (cin.get() == '\n')break;
  13.         else{
  14.             cin >> arr[jumlah];
  15.             jumlah++;
  16.         }
  17.     }
  18.     cout <<jumlah << endl;
  19.     //kuartil 1
  20.     posisi = (jumlah+2)/4;
  21.     cout << "Kuartal 1 : " << arr[posisi-1] << endl;
  22.  
  23.     //kuartil 2
  24.     posisi = (jumlah/2);
  25.     cout << "Kuartal 2 : " << (arr[posisi] + arr[posisi-1])/2 << endl ;
  26.  
  27.     //kuartil 3
  28.     posisi = (3*jumlah+2)/4;
  29.     cout << "Kuartal 3 : " << arr[posisi-1] ;
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement