Skip to content

Commit 723830d

Browse files
committed
Added more files.
1 parent 66e6e85 commit 723830d

7 files changed

Lines changed: 129 additions & 0 deletions

C++/02_cppBeginners.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
5+
6+
int main()
7+
{
8+
9+
cout << "hello world";
10+
return 0;
11+
}

C++/03_cppBeginners.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
5+
6+
int main()
7+
{
8+
9+
cout << "text";
10+
return 0;
11+
}

C++/04_cppBeginners.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
5+
6+
int main()
7+
{
8+
9+
int a = 4;
10+
int b = 21;
11+
12+
int sum = a + b;
13+
14+
cout << sum;
15+
return 0;
16+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class Main {
2+
3+
public static void main(String[] args) {
4+
5+
String[] words = { "funk", "chunk", "furry", "baconator" };
6+
7+
//startsWith
8+
for (String w: words) {
9+
if (w.startsWith("fu")) {
10+
System.out.println(w + " starts with fu");
11+
}
12+
}
13+
14+
//endsWith
15+
for (String w: words) {
16+
if (w.endsWith("unk")) {
17+
System.out.println(w + " ends with unk");
18+
}
19+
}
20+
21+
}
22+
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
public class Main {
2+
3+
public static void main(String[] args) {
4+
5+
String s = "buckyrobertsbuckyroberts";
6+
7+
System.out.println(s.indexOf("rob", 10));
8+
9+
String a = "BACON ";
10+
String b = "monster";
11+
String c = " flying ";
12+
13+
System.out.println(a.concat(b));
14+
15+
System.out.println(a.replace('B', 'F'));
16+
17+
System.out.println(b.toUpperCase());
18+
19+
System.out.println(a.toLowerCase());
20+
21+
System.out.println(c.trim());
22+
23+
}
24+
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Main {
2+
3+
//main
4+
public static void main(String[] args) {
5+
System.out.println(fact(5));
6+
}
7+
8+
//fact
9+
public static long fact(long n) {
10+
if (n <= 1) {
11+
return 1;
12+
}
13+
14+
return n * fact(n-1);
15+
}
16+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.*;
2+
3+
public class Main {
4+
5+
public static void main(String[] args) {
6+
7+
String[] things = {"eggs", "lasers", "hats", "pie" };
8+
List<String> list1 = new ArrayList<String>();
9+
10+
//add array items to list
11+
for (String x: things) {
12+
list1.add(x);
13+
}
14+
15+
String[] morethings = {"lasers", "hats" };
16+
List<String> list2 = new ArrayList<String>();
17+
18+
//add array items to list
19+
for (String y: morethings) {
20+
list2.add(y);
21+
}
22+
23+
for (int i = 0; i < list1.size(); i++) {
24+
System.out.printf("%s ", list1.get(i));
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)