Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. using namespace std;
  5. ifstream f("date.in");
  6. int x,y,m,i,start,nf,fin[25],poz,n,l,j,a[25][25];
  7. char c,sir[100];
  8. int main()
  9. {
  10. f >> m >> n;
  11. for(i = 1;i <= m;++i){
  12. f >> x >> y >> c;
  13. a[x][int(c-96)] = y;
  14. }
  15. /* for(i=1;i<=n;++i){
  16. for(j=1;j<=n;++j)
  17. cout<<a[i][j]<<" ";
  18. cout<<"\n";
  19. }
  20. */
  21. f >> start;
  22. f >> nf;
  23. for(i = 1;i <= nf;++i){
  24. f >> x;
  25. fin[x] = 1;
  26. }
  27.  
  28. cin.get(sir,100);
  29. poz = start;
  30. for(i = 0;i < strlen(sir);++i){
  31. c = int(sir[i]-'a'+1);
  32. if(a[poz][c])
  33. poz = a[poz][c];
  34. else{
  35. cout << "Nu apartine lui L(A)";
  36. break;
  37. }
  38. }
  39.  
  40. if(fin[poz] == 1)
  41. cout << "Apartine";
  42. else
  43. cout << "Nu apartine";
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement