Algoritma Pemrograman
- Iteratif C++ #include <iostream>
- Rekursif C++ #include <iostream>
- Raptor Rekursif
- Raptor Iteratif
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int i;
for(i=1;i<=100;i++){
if(i%5==0 && i%7==0){
cout<<i<< " ";
}
}
return 0;
}
#include <string>
using namespace std;
class R{
private:
int i,j;
public:
Bilangan(){i=1;j=100;}
int rekursif(int i,int j);
void rekursif();
};
int R::rekursif(int i,int j){
if (i<=100){
if (i%5==0 && i%7==0){
cout<<"Habis di bagi 5 dan 7 :"<<i<<endl;
}
return rekursif(i+1,j);}
}
int main(){
R r;
r.rekursif(1,100);
return 0;
}
EmoticonEmoticon