Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [DllImport("utils.dll", BestFitMapping = true, CallingConvention = CallingConvention.Cdecl)]
- public static extern bool MadeOf(char[] str, char[] from);
- // 49 seconds
- public static bool IsStringMadeOf(this string str, string from)
- {
- if (str.Length > from.Length) return false;
- return MadeOf((str + "\0").ToCharArray(), (from + "\0").ToCharArray());
- }
- C side;
- #include <string.h>
- extern "C" __declspec(dllexport) bool MadeOf(char str[], char from[])
- {
- int len1 = strlen(str);
- int len2 = strlen(from);
- for(int i= 0; i<len1; i++)
- {
- bool isExists = false;
- for(int j= 0; j < len2; j++)
- {
- if(str[i] == from[j])
- {
- from[j] = '?';
- isExists = true;
- break;
- }
- }
- if(!isExists)
- {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement