• API
• FAQ
• Tools
• Archive
daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <string>
3. #include <regex>
4. using namespace std;
5. int N;//the size of matrix.
6. char Matrix[50][50];
7. char str[50]={'0'};//store possible string.
8. char* create_string( char (*Matrix)[50], int N, int row, int col, char *str);
9. int main()
10. {
11.     int i,j;
12.     cin >> N;
13.     for(i=0;i<N;i++){
14.         for(j=0;j<N;j++){
15.             cin >> Matrix[i][j];
16.         }
17.     }
18.
19.     //start from every point to search the matching string.
20.     for(i=0 ;i<N; i++){
21.         for(j=0 ;j<N; j++){
22.             create_string(Matrix,N,i,j,str);
23.         }
24.     }
25.     return 0;
26. }
27.
28. char* create_string( char (*Matrix)[50], int N, int row, int col, char *str){
29.     //recursion to find valid string. start from Matix[i][j].
30.     static int i=0;
31.     //basic case.
32.     if(row+1==N && col)
33.     //recursive case.
34.     if(row+1<N){
35.             str[i] = Matrix[row][col];
36.             i++;
37.             create_string(Matrix,N,row+1,col,str);
38.     }
39.     if(col+1<N){
40.             str[i] = Matrix[row][col];
41.             i++;
42.             create_string(Matrix,N,row,col+1,str);
43.     }
44.     if(row-1<=0){
45.             str[i] = Matrix[row][col];
46.             i++;
47.             create_string(Matrix,N,row-1,col,str);
48.     }
49.     if(col-1<=0){
50.             str[i] = Matrix[row][col];
51.             i++;
52.             create_string(Matrix,N,row,col-1,str);
53.     }
54.     //once we find one, print out directly.
55.     //then sort this string to print with correct form(vowel in front of consonant.)
56.     return str;
57. }
58. void valid(char *str){
59.     regex expression("[^aeiou][aeiou]+([^aeiou][aeiou]+)+[^aeiou]");
60.
61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top