Guest User

Untitled

a guest
Jun 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. public static int smallaset_index1(int[] vec)
  2. {
  3. int J,small,index;
  4. small=vec[0];
  5. index=0;
  6. for (J=1;J<vec.Length;J++)
  7. {
  8. if (vec[J] > small)
  9. {
  10. small = vec[J];
  11. index = J;
  12. }
  13. }
  14. return J;
  15. }
  16. public static int smallaset_index2(int[] vec, int not)
  17. {
  18. int J, small, index;
  19. small = vec[0];
  20. index = 0;
  21. for (J = 0; J < vec.Length; J++)
  22. {
  23. if (J != not)
  24. {
  25. if (vec[J] > small)
  26. {
  27. small = vec[J];
  28. index = J;
  29. }
  30. }
  31. }
  32. return index;
  33. }
  34. public static bool check_num(int[] vec, int num)
  35. {
  36. int J=0,I;
  37. bool Flag=false;
  38. while ((J < vec.Length) && (!Flag))
  39. {
  40. if (vec[J] != num)
  41. {
  42. I=0;
  43. while ((I < vec.Length) && (!Flag))
  44. {
  45. if (vec[J]+vec[I]==num)
  46. Flag=true;
  47. I++;
  48. }
  49. }
  50. J++;
  51. }
  52. return Flag;
  53. }
  54. public static bool peula(int[] vec)
  55. {
  56. not1 = smallaset_index1(vec);
  57. not2 = smallaset_index2(vec);
  58. int I=0,J=0;;
  59. while (I < vec.Length)
  60. {
  61. if ((I != not1) && (I != not2))
  62. {
  63. if (check_num(vec, vec[I]))
  64. J++;
  65. }
  66. }
  67. return (J == vec.Length - 2);
  68. }
Add Comment
Please, Sign In to add comment