Jumat

Creating Recursive with C + +

Uh .... dach long nich not ngutak-ngatik C + +, soale most vent only, nach time this happened to me again the mood ngutak ngatik programming language C + +, perhaps odd that why all of a sudden I became ngutak-ngatik more C + +, this might be due to yesterday, yesterday is my friend that more college-level one, he asked "AA can make the task of recursive ga?" (Call the Sunda same boy who was above him) replied with a brief "I'm old dach ga tuch ngatik ngutak-recursive, but what can yach created, which nanyanya girl, I'm most abstinence to say no if asked for his help tuch girl, finally yach I'm also so ngutak-ngatik more C + +, but I'm most fond of klo asked that problems about delphi or pascal because it is a programming language my favorite, Lho kok so digress icon biggrin Creating Recursive with C + +, okay we are back kebahasan C + + happens to my friend who asked it has permasalahnnya with the matter as follows.
Problem First, the professor was asked to make a recursive function with C + + which accepts arguments an integer from 1 to n such klo we fed the value n equal to 10 then the results will be displayed on screen output 1 2 3 4 5 6 7 8 9 10
and so on according to the input value.
Problem two is still equal to the first question but the final output is an opposite example we klo its input value n equal to 10 then it will be displayed on screen.
10 9 8 7 6 5 4 3 2 1
With high spirit and enthusiasm, though already long not use C + +, finally see the answer like this, Answer the first question.


#include <iostream.h>

#include <conio.h>

void rekursif_angka(int);
main(){
int nomor;
cout<<”Silahkan masukan nilainya :”;
cin>>nomor;
rekursif_angka(nomor);
getch();
}
void rekursif_angka(int n){
if (n>=1){
rekursif_angka(n-1);
cout<<”\n”<<;;
}
}


Answer the second question.

 #include <iostream.h>

#include <conio.h>

void rekursif_angka_terbalik(int);
main(){
int nomor;
cout<<”Silahkan masukan nilainya :”;
cin>>nomor;
rekursif_angka_terbalik(nomor);
}
void rekursif_angka_terbalik(int n){
if (n>=1){
cout<<”\n”<<;;
rekursif_angka_terbalik(n-1);
}
}



Tidak ada komentar:

Posting Komentar