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.

156 lines
3.0 KiB

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <math.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 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;
}
// Function to calculate the sine of an angle in radians
float sine(float x) {
return sin(x);
}
// Function to calculate the cosine of an angle in radians
float cosine(float x) {
return cos(x);
}
// Function to calculate the tangent of an angle in radians
float tangent(float x) {
return tan(x);
}
// Function to calculate the arc sine of a value and return the result in radians
float arcSine(float x) {
if (x >= -1 && x <= 1) {
return asin(x);
}
else {
printf("Error: Invalid input for arc sine!\n");
return 0;
}
}
// Function to calculate the arc cosine of a value and return the result in radians
float arcCosine(float x) {
if (x >= -1 && x <= 1) {
return acos(x);
}
else {
printf("Error: Invalid input for arc cosine!\n");
return 0;
}
}
// Function to calculate the arc tangent of a value and return the result in radians
float arcTangent(float x) {
return atan(x);
}
// Function to convert degrees to radians
float degreesToRadians(float x) {
return x * (M_PI / 180);
}
// Function to convert radians to degrees
float radiansToDegrees(float x) {
return x * (180 / M_PI);
}
// Function to calculate the base 10 logarithm of a number and add 1
float logarithmPlusOne(float x) {
if (x > 0) {
return log10(x) + 1;
}
else {
printf("Error: Invalid input for logarithm + 1!\n");
return 0;
}
}
// Function to calculate the natural logarithm (base e) of a number and add 1
float naturalLogarithmPlusOne(float x) {
if (x > 0) {
return log(x) + 1;
}
else {
printf("Error: Invalid input for natural logarithm + 1!\n");
return 0;
}
}