0
0
This commit is contained in:
Guy Baconniere
2021-08-20 10:02:38 +02:00
parent 5aa02c94b5
commit d30270c485
354 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_iterative_power.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/18 10:51:08 by gbaconni #+# #+# */
/* Updated: 2021/08/18 10:51:14 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_iterative_power(int nb, int power)
{
int n;
if (power < 0)
n = 0;
else if (power == 0)
n = 1;
else
n = nb;
while (power > 0 && --power)
n *= nb;
return (n);
}

33
C_05/git/ex02/main.c Normal file
View File

@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/18 10:51:24 by gbaconni #+# #+# */
/* Updated: 2021/08/18 10:51:25 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int ft_iterative_power(int nb, int power);
int main(void)
{
int nb;
int power;
int result;
printf("Input Number: ");
scanf("%d", &nb);
printf("Input Power: ");
scanf("%d", &power);
result = ft_iterative_power(nb, power);
printf("nb=%d power=%d result=%d (ft_iterative_power)\n", nb, power, result);
return (0);
}

8
C_05/git/ex02/main.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out