Selasa, 23 April 2013

Alpro, "C++ nilai maksimum dan minimum rekursif"

#include <cstdlib>
#include <iostream> 
using namespace std;
class maxmin
  {      
   public:             
          maxmin();             
          int proses(int n,int max,int min,int jumlah);         
   private:              
          int n, max, min, jumlah, x;
  };

maxmin::maxmin()
{
cout<<"menampilkan maximum, minimum, dan jumlah sejumlah n        bilangan "<<endl;
}

int maxmin::proses(int n, int max, int min, int jumlah)
{
if(n==0)
  {cout<<"NILAI MAKSIMUM : "<<max<<endl;
   cout<<"NILAI MINIMUM : "<<min<<endl;
   cout<<"jumlah seluruh deret :"<<jumlah<<endl;
   return 0;
  }    

else
 {
   cout<<"masukkan bilangan :";cin>>x;
   jumlah+=x;

   if(x<min)
   {
      min=x;
   }         

   if(x>max)
   {
      max=x;
   }
    return proses(n-1,max,min,jumlah);
 }    


int main(int argc, char *argv[])
{
maxmin x;
x.proses(5,1,1,0);
system("PAUSE");

return EXIT_SUCCESS;
}

C++ nilai maksimum dan minimum rekursif

1 komentar:

ekuajadyne mengatakan...

Casino Poker Reviews - Casino TatsuTao
Casino Poker is an 365 bet innovative game where you will enjoy 라이브 바카라 the thrill of playing poker w88 dashboard while playing your favorite casino games 카드 게임 종류 like Blackjack, Roulette,  Rating: 3.2 · ‎1 스피드 바카라 review