The following is one example of a program to calculate the number of runs
#include <iostream.h>
#include <conio.h>
class deret{
friend ostream&operator<<(ostream&,deret&);
friend istream&operator>>(istream&,deret&);
public:
long arithmetic(int);
void print(int);
private:
int suku_n;
long results;
};
long deret::arithmetic(int n){
if(n==1)return 1;
else return n+arithmetic(n-1);
}
void deret::print(int n){
if (n>0){
cetak(n-1);
cout<<”suku ke : “<<n<<”=”<<hitung(n)<<endl;
}
}
istream&operator>>(istream&input,deret& x){
cout<<”Feedback integer : “;
input>>x.suku_n;
return input;
}
ostream&operator<<(ostream&output,deret&x){
output<<”number dere : “;
for (int i=1;i<=x.suku_n;i++)
if(i==x.suku_n)
cout<<i<<” is”<<endl;
else cout<<i<<”n “;
x.print(x.suku_n);
return output;
}
void main(){
row number;
cin>>number;
cout<<number<<endl;
system(“PAUSE”);
}
#include <iostream.h>
#include <conio.h>
class deret{
friend ostream&operator<<(ostream&,deret&);
friend istream&operator>>(istream&,deret&);
public:
long arithmetic(int);
void print(int);
private:
int suku_n;
long results;
};
long deret::arithmetic(int n){
if(n==1)return 1;
else return n+arithmetic(n-1);
}
void deret::print(int n){
if (n>0){
cetak(n-1);
cout<<”suku ke : “<<n<<”=”<<hitung(n)<<endl;
}
}
istream&operator>>(istream&input,deret& x){
cout<<”Feedback integer : “;
input>>x.suku_n;
return input;
}
ostream&operator<<(ostream&output,deret&x){
output<<”number dere : “;
for (int i=1;i<=x.suku_n;i++)
if(i==x.suku_n)
cout<<i<<” is”<<endl;
else cout<<i<<”n “;
x.print(x.suku_n);
return output;
}
void main(){
row number;
cin>>number;
cout<<number<<endl;
system(“PAUSE”);
}
Tidak ada komentar:
Posting Komentar