Quellcode durchsuchen

Lägg till saker gjorda i skolan. Lägg till *.out i gitignore

Jonatan Gezelius vor 6 Jahren
Ursprung
Commit
bbcbad931f
3 geänderte Dateien mit 76 neuen und 1 gelöschten Zeilen
  1. 2 1
      .gitignore
  2. 32 0
      p12468/p12468.cpp
  3. 42 0
      p696/p696.cpp

+ 2 - 1
.gitignore

@@ -1,6 +1,7 @@
 *.exe
 *.o
-
+*.out
+*.txt
 
 # Code Blocks specific
 *.cbp

+ 32 - 0
p12468/p12468.cpp

@@ -0,0 +1,32 @@
+#include <iostream>
+#include <cmath>
+
+using namespace std;
+
+
+int main()
+{
+	int a, b;
+
+	while(cin >> a >> b)
+	{
+		if(a == -1)
+			break;
+
+		int a_first = a - b;
+
+		if(a_first < 0)
+			a_first += 100;
+
+		int b_first = b - a;
+
+		if(b_first < 0)
+			b_first += 100;
+
+		cout << min(a_first, b_first) << endl;
+
+	}
+	
+	return 0;
+}
+

+ 42 - 0
p696/p696.cpp

@@ -0,0 +1,42 @@
+#include <iostream>
+#include <cmath>
+
+using namespace std;
+
+
+int main()
+{
+	int a, b, max_n;
+
+	while(cin >> a >> b)
+	{
+		if(!a && !b)
+			break;
+
+		if(!a || !b)
+		{
+			max_n = 0;
+		}
+		else if(a == 1 || b == 1)
+		{
+			max_n = a*b;
+			
+		}
+		else if(a == 2 || b == 2)
+		{
+			max_n = (max(a,b)/4) * 4;
+			max_n += max(a,b)%4 > 0 ? 2 : 0;
+			max_n += max(a,b)%4 > 1 ? 2 : 0;
+		}
+		else
+		{
+			max_n = ceil(a * b/2.0);
+		}
+
+					cout << max_n << " knights may be placed on a " << a << " row " << b << " column board." << endl;
+
+	}
+	
+	return 0;
+}
+