Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for rootman to be correct #2

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions math/fibonacci/main.c → c/math/fibonacci/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@

void f_fibonacci(int v_i)
{
long long int v_fibonacci[v_i];
int i;
v_fibonacci[0]=0;
v_fibonacci[1]=1;
for (i=-1;i<v_i;i++)
{
v_fibonacci[i+3]=v_fibonacci[i+2]+v_fibonacci[i+1];
printf("Durchlauf:\t%i\tfibonacci Zahl:\t%lli\n",i+1,v_fibonacci[i+1]);
}
long long int v_fibonacci[v_i];
int i;
v_fibonacci[0]=0;
v_fibonacci[1]=1;
for (i=-1;i<v_i;i++)
{
v_fibonacci[i+3]=v_fibonacci[i+2]+v_fibonacci[i+1];
printf("Durchlauf:\t%i\tfibonacci Zahl:\t%lli\n",i+1,v_fibonacci[i+1]);
}
}

void usage(char *program_name)
{
printf("Usage: %s <Genauigkeit>\n", program_name);
exit(1);
}
int main(int argc, char *argv[])
exit(1);
}
void main(int argc, char *argv[])
{
if(argc == 2)
{
int fibonacci = atoi(argv[1]);
f_fibonacci(fibonacci);
int fibonacci = atoi(argv[1]);
f_fibonacci(fibonacci);
}
else
{
usage(argv[0]);
usage(argv[0]);
}

}
83 changes: 83 additions & 0 deletions c/math/fraction2float/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* This program calculates a float out of a fraction.
Copyright (C) 2012 Fabian Nedoluha <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <stdlib.h>

long double fraction2float(int num, int denum)
{
long double result;

result = (float)num/denum;
return(result);
}

int get_longest(int num, int denum)
{
int longest,i;

for(i=1;num>10;i++)
{
num=num/10;
}
longest = i;
for(i=1;denum>10;i++)
{
denum=denum/10;
}
if(longest<i)
{
longest = i;
}
return(longest);
}

void print_fraction(int num, int denum, int count)
{
int i;

printf("%i\n", num);
for(i=1;i<=count;i++)
{
printf("-");
}
printf("\n%i", denum);
}

void usage(char *program_name)
{
printf("Usage: %s <numerator> <denominator>\n", program_name);
exit(1);
}

void main(int argc, char *argv[])
{
if(argc == 3)
{
int num, denum;

num = atoi(argv[1]);
denum = atoi(argv[2]);
print_fraction(num, denum, get_longest(num, denum));
printf(" = %Lf\n", fraction2float(num, denum));
exit(0);
}
else
{
usage(argv[0]);
}
}
File renamed without changes.
Loading