


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



public class Palindrome { public static boolean isPunc(char c){ if ((c==' ')|| (c==',')||(c =='.')||(c==':')|| (c==';')||(c=='!')||(c=='?')) return true; else return false; } public static void main(String[] args) { String s = args[0].toLowerCase(); boolean pal = true; for (int i=0, j=s.length()-1; i < j; i++, j--) { while (isPunc(s.charAt(i))) i++; while (isPunc(s.charAt(j))) j--; if (s.charAt(i) != s.charAt(j)) pal = false; } System.out.println(pal); } }
public class Client { public static void main (String[] args) { int N = Integer.parseInt(args[0]); Interval[] intervals = new Interval[N]; for (int i = 0; i < N; i++) { intervals[i] = new Interval(StdIn.readDouble(), StdIn.readDouble()); } for (int i = 0; i < N; i++){ for (int j = i + 1; j < N; j++) { if (intervals[i].intersects(intervals[j])) System.out.println(intervals[i] + " intersects " + intervals[j]); } } } }