You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.2 KiB
116 lines
2.2 KiB
#include <stdio.h>
|
|
#include "funktionen.h"
|
|
|
|
void welcome() {
|
|
char x[15];
|
|
printf("Hallo! Wie heisst du?\n");
|
|
scanf("%s", &x);
|
|
printf("\nSchöner Name, %s!\n\n", x);
|
|
}
|
|
|
|
int choose_program() {
|
|
int i;
|
|
|
|
printf("Welches der folgenden Programme moechtest du starten?\n1. Rechner.exe\n2. Gleichungen.exe\n3. TicTacToe.exe\n\n");
|
|
scanf("%d", &i);
|
|
|
|
return i;
|
|
}
|
|
|
|
int addThreeNumbers(int a, int b, int c) {
|
|
return a + b + c;
|
|
}
|
|
|
|
int multiply(int h, int g) {
|
|
return h * g;
|
|
}
|
|
|
|
int subtract(int num1, int num2) {
|
|
return num1 - num2;
|
|
}
|
|
|
|
int divide(int num1, int num2) {
|
|
return num1 / num2;
|
|
}
|
|
|
|
int power(int base, int power) {
|
|
int speicher = 1;
|
|
|
|
for (int i = 0; i < power; i++) {
|
|
speicher *= base;
|
|
}
|
|
|
|
return speicher;
|
|
}
|
|
|
|
int x_wins_00_10_20(char board[][3]) {
|
|
if (board[0][0] == 'X' && board[1][0] == 'X' && board[2][0] == 'X') {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int x_wins_01_11_21(char board[][3]) {
|
|
if (board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X') {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int x_wins_02_12_22(char board[][3]) {
|
|
if (board[0][2] == 'X' && board[1][2] == 'X' && board[2][2] == 'X') {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int x_wins_00_01_02(char board[][3]) {
|
|
if (board[0][0] == 'X' && board[0][1] == 'X' && board[0][2] == 'X') {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int x_wins_10_11_12(char board[][3]) {
|
|
if (board[1][0] == 'X' && board[1][1] == 'X' && board[1][2] == 'X') {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int x_wins_20_21_22(char board[][3]) {
|
|
if (board[2][0] == 'X' && board[2][1] == 'X' && board[2][2] == 'X') {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int x_wins_00_11_22(char board[][3]) {
|
|
if (board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X') {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int string_character_counter(char string[]) {
|
|
int stringLength = 0;
|
|
|
|
for (int i = 0; string[i] != '\0'; i++) {
|
|
stringLength++;
|
|
}
|
|
|
|
return stringLength;
|
|
}
|
|
|
|
int characterAppearanceInString(char c, char string[]) {
|
|
int appear = 0;
|
|
|
|
for (int i = 0; i < string_character_counter(string); i++) {
|
|
if (string[i] == c) {
|
|
appear++;
|
|
}
|
|
}
|
|
|
|
return appear;
|
|
}
|
|
|
|
int i(int v, int r) {
|
|
return v / r;
|
|
}
|
|
|
|
int p(int f, int a) {
|
|
return f / a;
|
|
}
|