Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5.  
  6. void scorr_fetta(int *px, int *pp, int lim1, int lim2, int lim3, int dimP, int *pm)
  7. {
  8.  
  9. int *temp1=px;
  10. int *temp2=pp;
  11. for(int u=0; u<lim2*lim1; u++)
  12. {
  13.  
  14. px= px+lim3*u;
  15.  
  16. int v=0;
  17. for(; (*px==*pp)&& v<dimP; v++)
  18. {
  19. px=px+lim3;
  20. pp=pp+1;
  21.  
  22. }
  23. if(v==dimP)
  24. {
  25. *pm=*(pm+1);
  26. u=u+v;
  27. }
  28. px=temp1;
  29. pp=temp2;
  30. }
  31.  
  32.  
  33. }
  34.  
  35. main(){
  36.  
  37. ifstream IN("input");
  38. ofstream OUT("output");
  39. int X[400]; for(int i=0; i<400; i++) X[i]=-1;
  40. int P[50];
  41.  
  42. int lim1=0, lim2=0, lim3=0;
  43. IN>>lim1 >>lim2 >>lim3;
  44.  
  45. int nel; IN>>nel; if(nel>lim1*lim2*lim3) nel=lim1*lim2*lim3;
  46. for(int i=0; i<nel; i++) {IN>> X[i];}
  47.  
  48. int dimP; IN>>dimP; if(dimP>50) dimP=50;
  49. for(int u=0; u<dimP; u++) {IN>>P[u];}
  50.  
  51.  
  52. for(int f=0; f<lim3 && f<nel; f++)
  53. {
  54. int *px=&X[f], *pp=P;
  55. int M=0, *pm=&M;
  56.  
  57. scorr_fetta(px, pp, lim1, lim2, lim3, dimP, pm );
  58. OUT<<"V-fetta "<<f<<'='<<M<<"match\n";
  59.  
  60. }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement