fork download
  1. #include <string.h>
  2. #include <stdlib.h>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <iostream>
  6.  
  7. int main()
  8. {
  9. int j1,j2,i;
  10. char d1[11],d2[11];
  11. char *p1;p1=(char*)malloc(sizeof(char)*5);
  12. char *p2;p2=(char*)malloc(sizeof(char)*5);
  13.  
  14. std::vector<int> v1;
  15. std::vector<int> v2;
  16. std::vector<char> result;
  17.  
  18. for(;;){
  19.  
  20. fflush(stdin);
  21. scanf("%d %d",&j1,&j2);
  22. fflush(stdin);
  23.  
  24. if(j1 == 0 && j2 == 0)
  25. {
  26. result.push_back('F');
  27. break;
  28. }
  29.  
  30. scanf("%[^\n]s",d1);
  31. fflush(stdin);
  32. scanf("%[^\n]s",d2);
  33. fflush(stdin);
  34.  
  35.  
  36. p1 = strtok(d1," ");
  37. while(p1 != '\0'){
  38.  
  39. v1.push_back(atoi(p1));
  40. p1 = strtok('\0'," ");
  41. }
  42.  
  43. p2 = strtok(d2," ");
  44. while(p2 != '\0'){
  45. v2.push_back(atoi(p2));
  46. p2 = strtok('\0'," ");
  47. }
  48.  
  49. std::sort(v1.begin(),v1.end());
  50. std::sort(v2.begin(),v2.end());
  51.  
  52. if(v1[0] == v2[1] || (v1[0] == v2[0] && v2[0] == v2[1])) result.push_back('N');
  53. else result.push_back('Y');
  54.  
  55. }
  56. std::cout <<"\n";
  57. for(i = 0;result[i] != 'F';i++)std::cout<< result[i] <<"\n";
  58. return 0;
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2 3
50 67
67 89 90
4 5
78 90 76 78
45 67 89 23 34
0 0
compilation info
prog.cpp:37:12: error: comparison between pointer and integer ('char *' and 'int')
                while(p1 != '\0'){
                      ~~ ^  ~~~~
prog.cpp:40:9: error: no matching function for call to 'strtok'
                        p1 = strtok('\0'," ");
                             ^~~~~~
/usr/include/string.h:343:14: note: candidate function not viable: no known conversion from 'char' to 'char *__restrict' for 1st argument
extern char *strtok (char *__restrict __s, const char *__restrict __delim)
             ^
prog.cpp:44:12: error: comparison between pointer and integer ('char *' and 'int')
                while(p2 != '\0'){
                      ~~ ^  ~~~~
prog.cpp:46:10: error: no matching function for call to 'strtok'
                                p2 = strtok('\0'," ");
                                     ^~~~~~
/usr/include/string.h:343:14: note: candidate function not viable: no known conversion from 'char' to 'char *__restrict' for 1st argument
extern char *strtok (char *__restrict __s, const char *__restrict __delim)
             ^
4 errors generated.
stdout
Standard output is empty