Monday, 31 March 2014

prosedur pencocokan string

#include <cstdlib>
#include <iostream>

using namespace std;

void Pencocokan(string P, string T,int n,int m,int idx){
     int i,j;
     bool ketemu;
     j=0;
     i=0;
     ketemu=false;
                  while (i<= n-m && !ketemu) {
                  j = 1;
                  };
                  while ((j<= m) && (P[j]=T[i+j]))
                  {
                  j=j+1;
                  }
                  if (j=m){
                  ketemu=true;
                  }
                   else{
                   i=i+1;
                   }
                         if (ketemu==true){
                         idx=i+1;
                         }
                   else {
                   idx = -1;
                   }

                   }

int main(int argc, char *argv[])
{
int idx;
Pencocokan("brondong","tua",2,4,idx);
system("PAUSE");
return EXIT_SUCCESS;
}

No comments:

Post a Comment

Konversi Suhu

#include <iostream> #include <conio.h> //#include <cstdlib> //#include <iostream.h> void main( float Celcius, Kelvi...