Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- int inc(char *c){
- if(c[0]==0) return 0;
- if(c[0]=='z'){
- c[0]='a';
- return inc(c+sizeof(char));
- }
- c[0]++;
- return 1;
- }
- int main(void){
- // int n = 3;
- // int i,j;
- //char *c = (char*)malloc(n+sizeof(char));
- // for(i=1;i<=n;i++){
- // for(j=0;j<i;j++){
- // c[j]='a';
- // }
- // c[i]=0;
- // do {
- // printf("%s\n",c);
- // } while(inc(c));
- // }
- // free(c);
- int n=3, numberOfNodes = 3, nodeNumber=1;
- char *c = (char*)malloc(n+sizeof(char));
- char *givenCharSet = {"abc"};
- int charSetLength = 0;
- int i,j,startingPoint,schrittWeite, incrementPoint;
- //get length of given input charset
- for(i=0;givenCharSet[i]!='\0';i++);
- charSetLength = i;
- //find out where to start brute-forcing from
- startingPoint = charSetLength / numberOfNodes * nodeNumber;
- schrittWeite = charSetLength / numberOfNodes;
- //create string to start incrementing from
- for(i=0;i < n; i++){
- if(i==0){
- c[i] = givenCharSet[startingPoint];
- continue;
- }
- c[i] = givenCharSet[0];
- }
- c[n]='\0';
- //start brute force
- incrementPoint = n - 1;
- do{
- for(incrementPoint = n-1;incrementPoint >=0;incrementPoint--){
- for(j=0;j < charSetLength;j++){
- c[incrementPoint] = givenCharSet[j];
- printf("%s\n",c);
- }
- }
- }
- while(c[0] != givenCharSet[startingPoint+schrittWeite]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement