Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5393c66

Browse files
Add files via upload
1 parent 1b8074c commit 5393c66

File tree

4 files changed

+521
-0
lines changed

4 files changed

+521
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*----------------------------------------------------------------------------------------------------------------------
2+
Sınıf Çalışması: Klavyeden alınan gün, ay ve yıl bilgilerine göre kişinin doğum günü geçmişse
3+
"geçmiş doğum gününü kutlu olsun", o an doğum günü ise "doğum gününüz kutlu olsun", doğum henüz gelmemişse
4+
"doğum gününüz şimdiden kutlu olsun" mesajlarından birini ekrana basan programı Calendar sınıfını kullanarak yazınız
5+
----------------------------------------------------------------------------------------------------------------------*/
6+
package org.csystem.app;
7+
8+
import org.csystem.util.Console;
9+
10+
import java.util.Calendar;
11+
12+
class App {
13+
public static void main(String[] args)
14+
{
15+
Calendar now = Calendar.getInstance();
16+
17+
Console.writeLine("%02d/%02d/%04d %02d:%02d:%02d.%03d",
18+
now.get(Calendar.DAY_OF_MONTH),
19+
now.get(Calendar.MONTH) + 1,
20+
now.get(Calendar.YEAR),
21+
now.get(Calendar.HOUR_OF_DAY),
22+
now.get(Calendar.MINUTE),
23+
now.get(Calendar.SECOND),
24+
now.get(Calendar.MILLISECOND));
25+
26+
now.set(Calendar.HOUR_OF_DAY, 10);
27+
28+
Console.writeLine("%02d/%02d/%04d %02d:%02d:%02d.%03d",
29+
now.get(Calendar.DAY_OF_MONTH),
30+
now.get(Calendar.MONTH) + 1,
31+
now.get(Calendar.YEAR),
32+
now.get(Calendar.HOUR_OF_DAY),
33+
now.get(Calendar.MINUTE),
34+
now.get(Calendar.SECOND),
35+
now.get(Calendar.MILLISECOND));
36+
}
37+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package org.csystem.samples.recurison;
2+
3+
public class RecursionUtil {
4+
private static int getFibonacciNumberRecur(int n)
5+
{
6+
if (n <= 2)
7+
return n - 1;
8+
9+
return getFibonacciNumberRecur(n - 1) + getFibonacciNumberRecur(n - 2);
10+
}
11+
12+
private static void getReverse(char [] c, int left, int right)
13+
{
14+
if (left >= right)
15+
return;
16+
17+
char temp;
18+
19+
temp = c[left];
20+
c[left] = c[right];
21+
c[right] = temp;
22+
23+
getReverse(c, left + 1, right - 1);
24+
}
25+
26+
private static void writeNumberRecur(int val)
27+
{
28+
if (val / 10 != 0)
29+
writeNumber(val / 10);
30+
31+
System.out.write((char)(val % 10 + '0'));
32+
}
33+
34+
private static void writeNumberRecur(int val, int radix)
35+
{
36+
if (val / radix != 0)
37+
writeNumberRecur(val / radix, radix);
38+
39+
//System.out.write((char)(val % radix >= 10 ? val % radix - 10 + 'A' : val % radix + '0'));
40+
System.out.write((char)((val % radix >= 10 ? - 10 + 'A' : '0') + val % radix));
41+
}
42+
43+
private static void writeReverse(String s, int i)
44+
{
45+
if (i == s.length())
46+
return;
47+
48+
writeReverse(s, i + 1);
49+
System.out.write(s.charAt(i));
50+
}
51+
52+
public static long factorial(int n)
53+
{
54+
if (n <= 0)
55+
return 1;
56+
57+
return n * factorial(n - 1);
58+
}
59+
60+
public static int getFibonacciNumber(int n)
61+
{
62+
if (n <= 0)
63+
return -1;
64+
65+
return getFibonacciNumberRecur(n);
66+
}
67+
68+
public static String getReverse(String s)
69+
{
70+
char [] c = s.toCharArray();
71+
72+
getReverse(c, 0, c.length - 1);
73+
74+
return String.valueOf(c);
75+
}
76+
77+
public static void writeNumber(int val)
78+
{
79+
if (val < 0) {
80+
System.out.write('-');
81+
val = -val;
82+
}
83+
writeNumberRecur(val);
84+
System.out.flush();
85+
}
86+
87+
public static void writeNumber(int val, int radix)
88+
{
89+
if (val < 0) {
90+
System.out.write('-');
91+
val = -val;
92+
}
93+
94+
writeNumberRecur(val, radix);
95+
System.out.flush();
96+
}
97+
98+
public static void writeReverse(String s)
99+
{
100+
writeReverse(s, 0);
101+
System.out.flush();
102+
}
103+
104+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.csystem.samples.recurison;
2+
3+
public class Util {
4+
5+
public static long factorial(int n)
6+
{
7+
long result = 1;
8+
9+
for (; n > 1; --n)
10+
result *= n;
11+
12+
return result;
13+
}
14+
15+
public static int getFibonacciNumber(int n)
16+
{
17+
if (n <= 0)
18+
return -1;
19+
20+
if (n <= 2)
21+
return n - 1;
22+
23+
int prev1 = 0, prev2 = 1, val = 0;
24+
25+
for (int i = 2; i < n; ++i) {
26+
val = prev1 + prev2;
27+
prev1 = prev2;
28+
prev2 = val;
29+
}
30+
31+
return val;
32+
}
33+
34+
public static String getReverse(String s)
35+
{
36+
return new StringBuilder(s).reverse().toString();
37+
}
38+
39+
public static void writeNumber(int val)
40+
{
41+
if (val == 0) {
42+
System.out.write('0');
43+
return;
44+
}
45+
46+
char [] s = new char[11];
47+
int i;
48+
boolean isNegative;
49+
isNegative = false;
50+
51+
if (val < 0) {
52+
isNegative = true;
53+
val = -val;
54+
}
55+
56+
for (i = 0; val != 0; ++i) {
57+
s[i] = (char)(val % 10 + '0');
58+
val /= 10;
59+
}
60+
if (isNegative)
61+
s[i++] = '-';
62+
63+
for (--i; i >= 0; --i)
64+
System.out.write(s[i]);
65+
66+
System.out.flush();
67+
}
68+
69+
public static void writeReverse(String s)
70+
{
71+
for (int i = s.length() - 1; i >= 0; --i)
72+
System.out.write(s.charAt(i));
73+
74+
System.out.flush();
75+
}
76+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /