Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. rekursif program (Recursive Program)

rekursif program (Recursive Program)

Scheduled Pinned Locked Moved Managed C++/CLI
database
2 Posts 2 Posters 16 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Achmad Roihan
    wrote on last edited by
    #1

    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

    OriginalGriffO 1 Reply Last reply
    0
    • A Achmad Roihan

      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

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      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!

      "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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups