Abi nako ug dugay ko mo answer naa na lain mo answer
Mura mas daghan cguro ang C#, VB & .NET programmers
Ug naa problema ang code, ikaw na bahala usab, similar pattern ra silaCode:/* 24. Write a Java class called AppearInOrder(), which defines a main() method that asks the user to enter two Strings subString and superString, and displays whether or not all the characters of subString appear in order in superString. You MUST NOT use any of the methods defined in the String class other than charAt() and length(). */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author javapenguin */ public class AppearInOrder { public static void main(String[] args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String superString = new String(); String subString = new String(); System.out.println("Please enter a super string: "); try { superString = input.readLine(); } catch (IOException ex) { System.err.println(ex); } System.out.println("Please enter a sub string: "); try { subString = input.readLine(); } catch (IOException ex) { System.err.println(ex); } int position = 0; boolean inOrder = true; for (int i = 0; i < subString.length(); i++) { for (int j = 0; j < superString.length(); j++) { if (subString.charAt(i) == superString.charAt(j)) { if (position>j) { inOrder = false; } else { position = j; break; } } } } if (inOrder) System.out.println("Character sequence is in order"); else System.out.println("Character is NOT in order"); } }
pahalipay
Code:/** * 17. Write a Java class called MaxConsecutiveOccurrences, which defines a * main() method that asks the user to enter a String s and a character c, * and displays the position in s at which the longest series of consecutive * occurrences of c occurs. If there is a tie between two positions, you * should return the lowest position. You MUST NOT use any of the methods * defined in the String class other than charAt() and length(). * * @author bishop__ */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class MaxConsecutiveOccurrences { public static void main(String[] args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String s = new String(); String ch = new String(); char c = ' '; System.out.println("Please enter a string: "); try { s = input.readLine(); } catch (IOException ex) { System.err.println(ex); } boolean invalid = true; while (invalid) { invalid = false; System.out.println(" "); System.out.println("Please enter a character: "); try { ch = input.readLine(); } catch (IOException ex) { System.err.println(ex); invalid = true; } if (ch.length() != 1) invalid = true; } c = ch.charAt(0); int found_at = -1; int most_occur = -1; int curr_occur_count = 0; int prev_occur_count = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == c) { // oi! nakit-an nako ang akong gi at-ngan! curr_occur_count++; // atong ihapon ug pila kabuok... plus 1 ta if (curr_occur_count == 1) found_at = i; // timan-an nato asa nato ug asa nga location unang nakita if (curr_occur_count > prev_occur_count) { // tan-awon ug kinsay labaw nila, ang bago nga ihap? or ang daan nga ihap? most_occur = found_at; // ah, milabaw ang bag-ong ihap, mao ni ang location sa may pinakadaghan nga nag sunod nga occurence sa letra nga atong gi at-ngan prev_occur_count = curr_occur_count; // ilisan nato ang daan natong ihap sa bag-o nato nga ihap } } else if (curr_occur_count > 0) { // walay nakit-an, ibalik nato ang atong ihap to 0 curr_occur_count = 0; } } if (most_occur != -1) { System.out.println("Max consecutive occurrence of \"" + ch + "\" is at " + most_occur); } else { System.out.println("Character \"" + ch + "\" not found in string!"); } } }
An example of a Discrete Mathematics problem.
usba lang ang message kun salikwaot basahon.
Code:/** * 23. Write a Java class called SubSet, which defines a main() method that * asks the user to enter two Strings superString and subString, and displays * whether or not all the characters of subString occur anywhere in * superString. You MUST NOT use any of the methods defined in the String * class other than charAt() and length(). * * @author bishop__ */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class SubSet { public static void main(String[] args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String superString = new String(); String subString = new String(); System.out.println("Please enter a Super string: "); try { superString = input.readLine(); } catch (IOException ex) { System.err.println(ex); } System.out.println("\nPlease enter a Sub string: "); try { subString = input.readLine(); } catch (IOException ex) { System.err.println(ex); } int count = 0; for (int x = 0; x < subString.length(); x++) { for (int y = 0; y < superString.length(); y++) { if (subString.charAt(x) == superString.charAt(y)) { count++; break; } } } if (count == subString.length()) { System.out.println("All characters inside \"" + subString + "\" can be FOUND inside \"" + superString + "\""); } else { System.out.println("NOT all characters inside \"" + subString + "\" can be FOUND inside \"" + superString + "\""); } } }
search nalang sa net part...
Fibonacci Sequence - Java - Source Code | DreamInCode.net
wew! tnx Bishop.....
2 nlng jud.... 11 & 14
mga masters of java man mu oi..
Similar Threads |
|