Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // PRE(T[limite_1][15][15] e' completamente definita, P[dim_P] e' completamente definita)
- int F(char (*T)[3][3], int limite_1, char P[], int dim_P)
- {
- int h = 0;
- bool primo = false;
- bool secondo = false;
- bool ok = false;
- int k = 0;
- while(k < limite_1)
- {
- for(int i = 0;i < 3;i++)
- { for(int j = 0;j < 3;j++)
- {
- if((T[k][i][j] == P[h]) && (h < dim_P))
- {
- ok = true;
- h++;
- }
- else if((T[k][i][j] != P [h]) && (h < dim_P))
- {
- ok = false;
- h = 0;
- }
- if((h == dim_P - 1) && (ok))
- {
- primo = true;
- }
- if((h == dim_P - 1) && (ok) && (primo))
- {
- secondo = true;
- }
- }
- }
- if(primo && secondo)
- {
- return k;
- }
- else
- {
- k++;
- }
- }
- if(secondo == false)
- {
- return -1;
- }
- }
- main()
- {
- char R[2][3][3] = { 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','s','o'};
- char A[3] = {'a','c','b'};
- int x = F(R,2,A,3);
- cout << x << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement