Skip to content

Commit

Permalink
Convert all CRLF to LF
Browse files Browse the repository at this point in the history
  • Loading branch information
howsiwei committed Jul 18, 2020
1 parent 2bc74cb commit 61941d4
Show file tree
Hide file tree
Showing 51 changed files with 3,413 additions and 3,413 deletions.
26 changes: 13 additions & 13 deletions .gitignore
@@ -1,13 +1,13 @@
*.aux
*.bak
*.log
*.ind
*.bbl
*.sav
*.blg
*.idx
*.out
*.ilg
*.exe
*.class
*.stackdump
*.aux
*.bak
*.log
*.ind
*.bbl
*.sav
*.blg
*.idx
*.out
*.ilg
*.exe
*.class
*.stackdump
30 changes: 15 additions & 15 deletions README.md
@@ -1,15 +1,15 @@
# cpbook-code
CP4 Free Source Code Project (cpp/gnu++17, java/java11, py/python3, and ml/ocaml).

This repo is expected to be much more up-to-date than CP4 itself, that will go out to public on 19 July 2020.

All code in this repo are mostly (reasonably good, hopefully :) implementation of many well-known data structures and algorithms,
so you are free to copy, adapt, use the code (in your next programming contest or any other coding project).

Note to Computer Science educators worldwide: please include all the code discussed here in your plagiarism checker system as "excluded".
Please do NOT test your students to just (re-)code these basic data structures/algorithms verbatim as that is just reinventing the wheel.
Please test them with higher order thinking questions/problems that use these code instead.

We will be thankful if you cite us (Steven Halim, Felix Halim, Suhendry Effendy) when you use code in this repo.

This license is probably the most suitable: https://opensource.org/licenses/UPL
# cpbook-code
CP4 Free Source Code Project (cpp/gnu++17, java/java11, py/python3, and ml/ocaml).

This repo is expected to be much more up-to-date than CP4 itself, that will go out to public on 19 July 2020.

All code in this repo are mostly (reasonably good, hopefully :) implementation of many well-known data structures and algorithms,
so you are free to copy, adapt, use the code (in your next programming contest or any other coding project).

Note to Computer Science educators worldwide: please include all the code discussed here in your plagiarism checker system as "excluded".
Please do NOT test your students to just (re-)code these basic data structures/algorithms verbatim as that is just reinventing the wheel.
Please test them with higher order thinking questions/problems that use these code instead.

We will be thankful if you cite us (Steven Halim, Felix Halim, Suhendry Effendy) when you use code in this repo.

This license is probably the most suitable: https://opensource.org/licenses/UPL
2 changes: 1 addition & 1 deletion ch1/Ex_1.3.4.1/task12.py
@@ -1 +1 @@
print(eval(input()))
print(eval(input()))
16 changes: 8 additions & 8 deletions ch1/moscowdream.cpp
@@ -1,8 +1,8 @@
#include <bits/stdc++.h> // a good practice in CP
using namespace std; // same as above
int main() {
int a, b, c, n; scanf("%d %d %d %d", &a, &b, &c, &n); // bug fix below
printf(((a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3)) ?
"YES\n" : "NO\n"); // use ternary operator
return 0; // for shorter code
}
#include <bits/stdc++.h> // a good practice in CP
using namespace std; // same as above
int main() {
int a, b, c, n; scanf("%d %d %d %d", &a, &b, &c, &n); // bug fix below
printf(((a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3)) ?
"YES\n" : "NO\n"); // use ternary operator
return 0; // for shorter code
}
16 changes: 8 additions & 8 deletions ch1/moscowdream.java
@@ -1,8 +1,8 @@
import java.util.*;
class moscowdream {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), n = sc.nextInt();
System.out.println(((a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3)) ? "YES" : "NO");
}
}
import java.util.*;
class moscowdream {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), n = sc.nextInt();
System.out.println(((a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3)) ? "YES" : "NO");
}
}
20 changes: 10 additions & 10 deletions ch1/moscowdream.ml
@@ -1,10 +1,10 @@
open Scanf
open Printf

let () =
scanf "%d %d %d %d\n" (fun a b c n ->
if (a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3) then
printf "YES\n"
else
printf "NO\n"
)
open Scanf
open Printf

let () =
scanf "%d %d %d %d\n" (fun a b c n ->
if (a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3) then
printf "YES\n"
else
printf "NO\n"
)
4 changes: 2 additions & 2 deletions ch1/moscowdream.py
@@ -1,2 +1,2 @@
a, b, c, n = map(int, input().split())
print("YES" if ((a >= 1) and (b >= 1) and (c >= 1) and (a+b+c >= n) and (n >= 3)) else "NO");
a, b, c, n = map(int, input().split())
print("YES" if ((a >= 1) and (b >= 1) and (c >= 1) and (a+b+c >= n) and (n >= 3)) else "NO");
60 changes: 30 additions & 30 deletions ch2/lineards/UVa10925.java
@@ -1,30 +1,30 @@
import java.io.*;
import java.util.*;
import java.math.BigInteger; // in package java.math

class Main { // UVa 10925 - Krakovia
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader( // use BufferedReader
new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter( // and PrintWriter
new BufferedWriter(new OutputStreamWriter(System.out))); // = fast IO
int caseNo = 0;
while (true) {
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken()); // N bills
int F = Integer.parseInt(st.nextToken()); // F friends
if (N == 0 && F == 0) break;
BigInteger sum = BigInteger.ZERO; // built-in constant
for (int i = 0; i < N; ++i) { // sum the N large bills
BigInteger V = new BigInteger(br.readLine()); // string constructor
sum = sum.add(V); // BigInteger addition
}
pw.printf("Bill #%d costs ", ++caseNo);
pw.printf(sum.toString());
pw.printf(": each friend should pay ");
pw.printf(sum.divide(BigInteger.valueOf(F)).toString());
pw.printf("\n\n"); // divide to F friends
}
pw.close();
}
}
import java.io.*;
import java.util.*;
import java.math.BigInteger; // in package java.math

class Main { // UVa 10925 - Krakovia
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader( // use BufferedReader
new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter( // and PrintWriter
new BufferedWriter(new OutputStreamWriter(System.out))); // = fast IO
int caseNo = 0;
while (true) {
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken()); // N bills
int F = Integer.parseInt(st.nextToken()); // F friends
if (N == 0 && F == 0) break;
BigInteger sum = BigInteger.ZERO; // built-in constant
for (int i = 0; i < N; ++i) { // sum the N large bills
BigInteger V = new BigInteger(br.readLine()); // string constructor
sum = sum.add(V); // BigInteger addition
}
pw.printf("Bill #%d costs ", ++caseNo);
pw.printf(sum.toString());
pw.printf(": each friend should pay ");
pw.printf(sum.divide(BigInteger.valueOf(F)).toString());
pw.printf("\n\n"); // divide to F friends
}
pw.close();
}
}
30 changes: 15 additions & 15 deletions ch2/lineards/UVa10925.py
@@ -1,15 +1,15 @@
import sys
inputs = sys.stdin.read().splitlines() # make Python I/O faster
caseNo = 1
ln = 0
while True:
N, F = map(int, inputs[ln].split()) # N bills, F friends
ln += 1
if N == 0 and F == 0: break
sum = 0 # native support
for _ in range(N): # sum the N large bills
sum += int(inputs[ln]) # native Big Integer
ln += 1
print("Bill #%d costs %d: each friend should pay %d\n"
% (caseNo, sum, sum//F)) # integer division
caseNo += 1
import sys
inputs = sys.stdin.read().splitlines() # make Python I/O faster
caseNo = 1
ln = 0
while True:
N, F = map(int, inputs[ln].split()) # N bills, F friends
ln += 1
if N == 0 and F == 0: break
sum = 0 # native support
for _ in range(N): # sum the N large bills
sum += int(inputs[ln]) # native Big Integer
ln += 1
print("Bill #%d costs %d: each friend should pay %d\n"
% (caseNo, sum, sum//F)) # integer division
caseNo += 1

0 comments on commit 61941d4

Please sign in to comment.