pasqualerossi / 42-school-exam-rank-02 Goto Github PK
View Code? Open in Web Editor NEWFirst 42 School Exam
First 42 School Exam
when end is smaller than start, your function returns array that contains ints from start to end, but shouldn't it return from end to start? In example of subject ft_rrange(0, -3) should return {-3 , -2, -1 , 0}, but it returns {0, -1, -2, -3}.
Can you help me? I saw that the repository code has syntax errors. I fixed it, but I'm already in sext grademe and it still gives a compilation problem.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int i;
int num;
i = 2;
num = atoi(argv[1]);
if (argc == 2)
{
if (num == 1)
printf("1");
while(i <= num)
{
if (num % i == 0)
{
printf("%d", i);
if (num == i)
break;
printf("*");
num = num / i;
i = 2;
}
i++;
}
}
printf("\n");
}
The current FizzBuzz program has been enhanced to make it more interactive by allowing users to specify the range of numbers to consider. However, there's room for further improvement and refinement.
location : Level 1/ Fizzbuzz / fizzbuzz.c
Hi, in level 2 the max function, you are using type cast (int) in result;
I Didn't pass in the exam because of that, it wont work, moullinete wont pass.
Switch (int) type cast in Result to Unsigned int, and it will pass.
while(...)
....
else
{
res[i] = start;
start--;
i++;
}
You have a "else" after a while. In my knowledge that is a syntax error
when testing the programm with
./a.out "abc def "
the result is
abf abc$
with 2 spaces in betweeen. unfortunately i didnt find a solution for that in your code.
8 int get_digit(char c, int digits_in_base)
9 {
10 int max_digit;
11 if (digits_in_base <= 10)
12 max_digit = digits_in_base + '0';
13 else
14 max_digit = digits_in_base - 10 + 'a';
15 if (c >= '0' && c <= '9' && c <= max_digit)
16 return (c - '0');
17 else if (c >= 'a' && c <= 'f' && c <= max_digit)
18 return (10 + c - 'a');
19 else
20 return (-1);
21 }
In the line 15 and line 17, the condition is wrong. In any base
inside tab_mult the functions ft_atoi & ft_putnbr are handeling cases where the given number (parameter) is negative which is not asked in subject and could be removed to improve readability. Also could add a checker if the number is <= 238609183, as this is the highest number to be multiplied by 9 and still fit in an int.
Subject.txt:
Write a program that displays a number's multiplication table.
The parameter will always be a strictly positive number that fits in an int,
and said number times 9 will also fit in an int.
If there are no parameters, the program displays \n.
(ignore)
Hey there, I was just reviewing some code before the exam and I believe I crossed somethingthat is probably wrong.
You got an undefined variable named "number 2" in the pgcd.c file, so the program doesnt even compile :)
Check it out and let me know whats up!
This code gets success in grademe but not in the official exam.
int ft_atoi_base(const char *str, int str_base)
{
int result;
int i;
int sign;
i = 0;
sign = 1;
result = 0;
if (str[i] == '-' || str[i] == '+')
{
if (str[i] == '-')
sign = -1;
i++;
}
while (str[i] != '\0')
{
if (str[i] >= '0' && str[i] <= '9')
result = result * str_base + str[i] - '0';
else if (str[i] >= 'a' && str[i] <= 'f')
{
result = result * str_base;
result = result + str[i] - 'a' + 10;
}
else if (str[i] >= 'A' && str[i] <= 'F')
{
result = result * str_base;
result = result + str[i] - 'A' + 10;
}
else
return (result * sign);
i++;
}
return (result * sign);
}
The ft_split solution use strlen but the only function allowed is malloc
The array "seen" needs to be of type unsigned char to match the range of possible values for warning flags enabled in compilation
in add_prime_sum, it doesnt handle case "./a.out"
need to add
else
put_nbr(0);
after
if (argc == 2) statement
there is a problem in ft_range function in line 10 and 12
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.