-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStdInOut.java
More file actions
137 lines (109 loc) · 4.44 KB
/
StdInOut.java
File metadata and controls
137 lines (109 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package org.HackerRank;
import java.io.*;
import java.util.*;
public class StdInOut {
public static void main(String[] args) throws IOException {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
/* Scanner scanner = new Scanner(System.in);
int myInt = scanner.nextInt();
double myDbl = scanner.nextDouble();
String myStr = scanner.nextLine();
scanner.close();
System.out.println("String: " + myStr);
System.out.println("Double: " + myDbl);
System.out.println("Int: " + myInt);*/
/*
Scanner scanner = new Scanner(System.in);
String firstStr = scanner.next();
int firstInt = scanner.nextInt();
String secondStr = scanner.next();
int secondInt = scanner.nextInt();
String thirdStr = scanner.next();
int thirdInt = scanner.nextInt();
System.out.printf("%-15s", firstStr);
System.out.printf("%03d", firstInt);
System.out.println();
System.out.printf("%-15s", secondStr);
System.out.printf("%03d", secondInt);
System.out.println();
System.out.printf("%-15s", thirdStr);
System.out.printf("%03d", thirdInt);
*/
/* BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bufferedReader.readLine().trim());
for(int i=1; i<=10; i++) {
System.out.println(n + " x " + i + " = " + (n*i));
}
bufferedReader.close();*/
/* Scanner scanner = new Scanner(System.in);
int nLines = scanner.nextInt();
scanner.nextLine();
int[] a = new int[nLines];
int[] b = new int[nLines];
int[] n = new int[nLines];
for(int i =0; i<nLines; i++) {
a[i] = scanner.nextInt();
b[i] = scanner.nextInt();
n[i] = scanner.nextInt();
scanner.nextLine();
}
scanner.close();
for(int k =0; k<nLines; k++) {
printOut(a[k], b[k], n[k]);
}*/
/*Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt(); // number of test cases
List<String> results = new ArrayList<>(); // store results
for (int i = 0; i < t; i++) {
try {
long num = scanner.nextLong(); // reading the input number
StringBuilder result = new StringBuilder(num + " can be fitted in:\n");
// Check for byte (-128 to 127)
if (num >= Byte.MIN_VALUE && num <= Byte.MAX_VALUE) {
result.append("* byte\n");
}
// Check for short (-32,768 to 32,767)
if (num >= Short.MIN_VALUE && num <= Short.MAX_VALUE) {
result.append("* short\n");
}
// Check for int (-2^31 to 2^31 - 1)
if (num >= Integer.MIN_VALUE && num <= Integer.MAX_VALUE) {
result.append("* int\n");
}
// Check for long (-2^63 to 2^63 - 1)
if (num >= Long.MIN_VALUE && num <= Long.MAX_VALUE) {
result.append("* long\n");
}
results.add(result.toString()); // add to results list
} catch (Exception e) {
// If the number exceeds the long range
results.add(scanner.next() + " can't be fitted anywhere.\n");
}
}
scanner.close();
// Output all results
for (String result : results) {
System.out.print(result);
}*/
Scanner scanner = new Scanner(System.in);
List<String> lines = new ArrayList<>(); // List to store all lines
// Scan all input lines and store them in the list
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
lines.add(line); // Store each line in the list
}
scanner.close(); // Close the scanner
// Now print all lines with their line numbers
for (int i = 0; i < lines.size(); i++) {
System.out.println((i + 1) + " " + lines.get(i)); // Print with line number
}
}
public static void printOut(int a, int b, int n) {
int res = a;
for(int j = 0; j < n;j ++) {
res = (int)(res + (Math.pow(2, j)*b));
System.out.print(res + " ");
}
System.out.println();
}
}