Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. public static int[] findConflictingStudent(int[] schedule, String[] students, String[] courses,
  2. int[][] studentCourses, int k) {
  3. boolean isLegal = true;
  4. int[] output = new int[4];
  5. int[] legal = new int[0];
  6.  
  7.  
  8. for (int i = 0; i < schedule.length & isLegal == true; i = i + 1) {
  9. for (int j = 0; j < schedule.length & isLegal == true; j = j + 1) {
  10. if (i != j && schedule[i] == schedule[j]) { // check if there
  11. // are two exams at
  12. // the same day
  13. for (int m = 0; m < studentCourses.length & isLegal == true; m = m + 1) {// check
  14. // if
  15. // there
  16. // is
  17. // a
  18. // student
  19. // is
  20. // registered
  21. // to
  22. // both
  23. // courses
  24. boolean isFirstCourse = false;
  25. boolean isSecondCourse = false;
  26. for (int f = 0; f < studentCourses[m].length & isFirstCourse == false; f = f + 1)
  27. if (studentCourses[m][f] == i) {
  28. isFirstCourse = true;
  29. output[1] = m;
  30. output[2] = studentCourses[m][f];
  31. }
  32.  
  33. for (int g = 0; g < studentCourses[m].length & isSecondCourse == false; g = g + 1)
  34. if (studentCourses[m][g] == j) {
  35. isSecondCourse = true;
  36. output[3] = studentCourses[m][g];
  37. output[0] = schedule[i];
  38. }
  39. if(isFirstCourse&isSecondCourse)
  40. isLegal=false;
  41.  
  42.  
  43. }
  44. }
  45. }
  46.  
  47.  
  48.  
  49. }
  50. if (isLegal==false)
  51. return output;
  52.  
  53. else
  54.  
  55. return legal;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement