Master this posture, girlfriend no longer talks about

2023-01-23   ES  

If the characters of the two string are the same, but the order is different, it is considered a brothers strings. For example, BAD and ADB are brothers string, which now provides a string, how to quickly find its brother string in the dictionary in the dictionary ,,

Please describe the data structure and query process.

#include <stdio.h> 
 #include <stdlib.h> 
 #include <string.h> 

 /* 
  *Test the string 
  */ 
 char * substring (char * src, int pos, int len) { 
 char *p = src; 
 char *substr = calloc (sizeof (char), len + 1); 
 int i = 0; 
 p += pOS; 
 While (len-) { 
 substr [i ++] = *(p ++); 
 } 
 substr [i] = '\ 0'; 
 Return substr; 
 } 

 int Gethash (char *p) { 
 int Hash = 0; 
 int length = strlen (p); 
 int i = 0; 
 for (; I <langth; i ++) { 
 have | = (1 << (p [i] -'a')); 
 } 
 Return have; 
 } 

 Void Sibilingstring (Char* Dict, Char* Target) { 
 int size = strlen (dict); 
 int Start = 0; 
 int Len = Strlen (target); 
 int END = Len -1; 
 int targethash = gethash (target); 
 While (END ++ <SIZE) { 
 char *substr = substring (Dict, Start ++, Len); 
 /*If you want to be consistent with the brothers' string* / 
 ifThash (Substr) == Targethash) { 
 puts (substr); 
 } 
 } 

 } 

 int Main (void) { 
 char *src = "worldhello"; 
 puts ("Sibiling Strings:"); 
 sibilingstring (src, "heoll"); 
 Return exit_success; 
 }

source

Related Posts

4.4-Delete container

[DCMTK] Excessive information of the console

Javaweb Note — HTML/CSS Basic Learning 2 (Writing Specification of HTML File)

Machine learning to process the 95 -point digital blocking method of the discrete value method

Master this posture, girlfriend no longer talks about

Random Posts

DQN-Experience Realization (Simple)

Machine learning entry-liver disease prediction analysis

[Game interaction design] How to use interactive thinking to create a more sense of substitution? Netease

Mac Android Studio commonly used shortcut key corresponding to the keymap value

A solution to AndroidStudio introduced a problem with the problem that the Module occurred.