rekursif program (Recursive Program)
-
fungsi program adalah menghilangkan karakter yang sama sehingga karakter tersebut hanya munsul satu kali dengan menggunakan rekursif perogram ku blm sempurnah
Google Translate:
the function of the program is to remove the same character so that the character appears only once by using recursive my program is not perfect
#include
#include
using namespace std;int main(){
char nama[1000];
int index[100];
cout<<"masukkan nama = ";for(int i=0; i
-
fungsi program adalah menghilangkan karakter yang sama sehingga karakter tersebut hanya munsul satu kali dengan menggunakan rekursif perogram ku blm sempurnah
Google Translate:
the function of the program is to remove the same character so that the character appears only once by using recursive my program is not perfect
#include
#include
using namespace std;int main(){
char nama[1000];
int index[100];
cout<<"masukkan nama = ";for(int i=0; i
This is an English language site, and we can only accept and answer questions in that language. I have run this through Google Translate to produce a probably-good version, but you should check it and make sure it does say what you are actually asking. And that code isn't recursive: it's iterative. Recursion happens when a function calls itself, either directly:
int foo(int i)
{
if (i <= 1) return 1;
return i + foo(i - 1);
}Or indirectly:
int foo(int i)
{
if (i <= 1) return 1;
return i + bar(i);
}
int bar(int i)
{
return foo(i - 1);
}Your code contains one method, which you do not call yourself! And please, do yourself a favour and indent your code more deeply - it's a lot easier to see what is going on with three or four spaces per indent rather than one. It's not a massive problem with a tiny code fragment like you show, but as your code gets bigger it becomes seriously difficult to work out what is going on!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!