Moved kattis from Uni repo

This commit is contained in:
2023-12-01 13:35:13 +01:00
parent 28a6b807a3
commit aaa2c123b8
164 changed files with 3008 additions and 0 deletions

View File

@ -0,0 +1,5 @@
4
-1 1 -1 2
9 -1 -1 -1
-1 3 -1 4
7 1 2 -1

View File

@ -0,0 +1,36 @@
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
void directFlights(int n, int flights[MAX][MAX]) {
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
if (flights[i][j] != -1) {
printf("%d %d %d\n", i+1, j+1, flights[i][j]);
}
}
}
return;
}
int main(int argc, char **argv) {
int n;
int flights[MAX][MAX];
scanf("%d", &n);
int counter = 0;
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
scanf("%d", &flights[i][j]);
if (flights[i][j] != -1) {
counter++;
}
}
}
printf("%d\n", counter);
directFlights(n, flights);
return 0;
}

View File

@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
void trip(int i, int j, int flights[MAX][MAX]) {
if (flights[i][j] == -1) {
return;
}
printf("%d", flights[i][j]);
trip(j, flights[i][j], flights);
return;
}
void directFlights(int n, int flights[MAX][MAX]) {
for (int i=0; i<n; i++) {
int printed = 0;
for (int j=0; j<n; j++) {
if (flights[i][j] != -1) {
if (printed) {
printf(" ");
}
printed = 1;
trip(i, j, flights);
}
}
printf("\n");
}
return;
}
int main(int argc, char **argv) {
int n;
int flights[MAX][MAX];
scanf("%d", &n);
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
scanf("%d", &flights[i][j]);
}
}
directFlights(n, flights);
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,2 @@
ho|lo
pe|ve

View File

@ -0,0 +1,2 @@
ekki |daudi
opna| inni

View File

@ -0,0 +1,72 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 2100
int isAlpha(char c) {
if (c >= 'a' && c <= 'z') {
return 1;
}
if (c >= 'A' && c <= 'Z') {
return 1;
}
return 0;
}
void printBefore(char first[MAX], char second[MAX]) {
for (int i=0; i<strlen(first); i++) {
if (first[i] == '|') {
break;
}
if (isAlpha(first[i])) {
printf("%c", first[i]);
}
}
for (int i=0; i<strlen(second); i++) {
if (second[i] == '|') {
break;
}
if (isAlpha(second[i])) {
printf("%c", second[i]);
}
}
printf(" ");
}
void printAfter(char first[MAX], char second[MAX]) {
int pipeFound = 0;
for (int i=0; i<strlen(first); i++) {
if (pipeFound && isAlpha(first[i])) {
printf("%c", first[i]);
}
if (first[i] == '|') {
pipeFound = 1;
}
}
pipeFound = 0;
for (int i=0; i<strlen(second); i++) {
if (pipeFound && isAlpha(second[i])) {
printf("%c", second[i]);
}
if (second[i] == '|') {
pipeFound = 1;
}
}
printf("\n");
}
int main(int argc, char **argv) {
char first[MAX];
char second[MAX];
scanf("%s %s", first, second);
printBefore(first, second);
printAfter(first, second);
return 0;
}

View File

@ -0,0 +1,68 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 2100
int isAlpha(char c) {
if (c >= 'a' && c <= 'z') {
return 1;
}
if (c >= 'A' && c <= 'Z') {
return 1;
}
return 0;
}
void printBefore(char first[MAX], char second[MAX]) {
for (int i=0; i<strlen(first); i++) {
if (first[i] == '|') {
break;
}
if (isAlpha(first[i])) printf("%c", first[i]);
}
for (int i=0; i<strlen(second); i++) {
if (second[i] == '|') {
break;
}
if (isAlpha(second[i])) printf("%c", second[i]);
}
printf(" ");
}
void printAfter(char first[MAX], char second[MAX]) {
int pipeFound = 0;
for (int i=0; i<strlen(first); i++) {
if (pipeFound) {
printf("%c", first[i]);
}
if (first[i] == '|' && isAlpha(first[i])) {
pipeFound = 1;
}
}
pipeFound = 0;
for (int i=0; i<strlen(second); i++) {
if (pipeFound) {
printf("%c", second[i]);
}
if (second[i] == '|' && isAlpha(second[i])) {
pipeFound = 1;
}
}
printf("\n");
}
int main(int argc, char **argv) {
char first[MAX];
char second[MAX];
scanf("%s %s", first, second);
printBefore(first, second);
printAfter(first, second);
return 0;
}

View File

@ -0,0 +1,4 @@
first = input().split("|")
second = input().split("|")
print(first[0] + second[0] + " " + first[1] + second[1])

Binary file not shown.

View File

@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int n, m;
scanf("%d %d", &n, &m);
printf("%d\n", n - (n/m)*m );
return 0;
}

View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int x,y,z;
scanf("%d/%d/%d", &x, &y, &z);
// EU OR US OR EITHER
if (x > 12) {
printf("EU\n");
} else if (y > 12) {
printf("US\n");
} else {
printf("either\n");
}
return 0;
}

View File

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
typedef struct Transaction {
int amount;
char *service;
} Transaction;
int main(int argc, char **argv) {
Transaction x, y, z;
x.service = "Monnei";
y.service = "Fjee";
z.service = "Dolladollabilljoll";
scanf("%d %d %d", &x.amount, &y.amount, &z.amount);
// Get min
Transaction min = x;
if (y.amount < min.amount) {
min = y;
}
if (z.amount < min.amount) {
min = z;
}
printf("%s\n", min.service);
return 0;
}