Guest User

Untitled

a guest
May 21st, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. /*-------------------------------------------------------------------------
  2. Include files:
  3. --------------------------------------------------------------------------*/
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8.  
  9.  
  10. /*=========================================================================
  11. Constants and definitions:
  12. ==========================================================================*/
  13.  
  14. /* put your #defines and typedefs here*/
  15.  
  16.  
  17.  
  18. /*-------------------------------------------------------------------------
  19. The main program. (describe what your program does here)
  20. -------------------------------------------------------------------------*/
  21. int main()
  22. {
  23. /*char movies_info[9][10] = {"Drama","Mystery","Crime","Cabbola","Noga","Flincher","Pacico","Pearcing","Pittbull"}; */
  24. char movies [10][100];
  25. int criterion[3];
  26. /* char * p;*/
  27. int c;
  28. int i=0,j=0;
  29. printf("Please enter the first criterion index \n");
  30. scanf("%d",&criterion[0]);
  31. printf("Please enter the second criterion index \n");
  32. scanf("%d",&criterion[1]);
  33. printf("Please enter the third criterion index \n");
  34. scanf("%d",&criterion[2]);
  35. getchar();
  36. printf("Please enter the movies list :\n");
  37.  
  38.  
  39. c = getchar();
  40. ungetc(c,stdin);
  41. for(i=0;c != EOF;i++)
  42. {
  43. c = getchar();
  44. ungetc(c,stdin);
  45. for(j=0;c != '\n' && c != EOF;j++)
  46. {
  47. c = getchar();
  48. if(c != '\n' && c != EOF)
  49. movies[i][j] = c;
  50.  
  51. else if(c == '\n')
  52. {
  53. movies[i][j] = '\0';
  54. break;
  55. }
  56. else if(c == EOF)
  57. { movies[i][j] = '\0';
  58. break;
  59. }
  60. }
  61. }
  62.  
  63. c = movies[0][0];
  64. for(i=0;(c >= 0 && c <= 127);i++)
  65. {
  66. for(j=0;c != '\0';j++)
  67. {
  68. printf("%c",movies[i][j]);
  69. c = movies[i][j];
  70. }
  71. c = movies[i+1][0];
  72. printf("\n");
  73. }
  74.  
  75. return 0;
  76.  
  77. }
  78.  
  79. void must_see_movie(char movies [][100],char movies_info[9][10],unsigned int num [3])
  80. {
  81. int rank[10] = {0};
  82. int i,j,h;
  83. char * cretrion , * p = &movies[0][0],* check;
  84.  
  85.  
  86. for(i=0;(*p >= 0 && *p <= 127);i++)
  87. {
  88. p = &movies[i][0];
  89. for(h=0;h<3;h++)
  90. {
  91. cretrion = &movies_info[num[h]][0];
  92. check = strstr(*p,*cretrion);
  93. if(check != NULL)
  94. rank[i]++;
  95. }
  96. }
  97.  
  98. for(j=0;j<=i;j++)
  99. printf("%d",rank[j]);
  100.  
  101.  
  102. }
Add Comment
Please, Sign In to add comment