tech.shekharsaxena
BAN USERpublic class ReverseDigitPrint {
public static void main(String[] args) {
printReverse(391, -1);
}
public static void printReverse(int digit, int reminder) {
if (digit <= 0) {
return;
}
reminder = digit % 10;
if (reminder != -1) {
System.out.print(reminder);
}
digit = digit / 10;
printReverse(digit, reminder);
}
}
public class MakeUpperLetter {
public static void main(String[] args) {
String str = "careercup";
char[] chars = str.toCharArray();
if(chars[0] >= 97 && chars[0] <= 122) {
chars[0] = (char)(chars[0] - 32);
}
for(int i = 0; i <chars.length; i++) {
System.out.print(chars[i]);
}
}
}
public class ReadMatrix {
- tech.shekharsaxena October 07, 2016public static void main(String[] args) {
int[][] array = {{1, 2, 3 , 11}, {4, 5, 9 ,12}, {7, 8, 9,13},{14,15,16,17}};
int[] output = new int[array.length*array.length];
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array.length; j++) {
System.out.print(array[i][j] + " ");
}
System.out.println(" ");
}
int left = 0;
int right = array.length - 1;
int arrayIndex = 0;
int index = 0;
String direction = "f";
while (left <= array.length -1) {
if (direction.equals("f")) {
index = 0;
while (index <= right) {
output[arrayIndex] = array[left][index];
arrayIndex++;
index++;
}
}
left++;
direction = "b";
if (direction.equals("b") && left<= array.length -1) {
index = array.length - 1;
while (index >= 0) {
output[arrayIndex] = array[left][index];
arrayIndex++;
index--;
}
}
left++;
direction = "f";
}
for (int j = 0; j < output.length; j++) {
System.out.print(output[j] + " ");
}
}
}