-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathniu.c
42 lines (36 loc) · 1.01 KB
/
niu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void ft_putchar(char c){
write(1,&c,1);
}
void putnbr(int nbr){
if(nbr<0){
ft_putchar('-');
nbr *=-1;
}
if(nbr>9){
putnbr(nbr/10);
}
ft_putchar(nbr%10 + '0');
}
int main(int ac,char* av[])
{
int i =atoi(av[1]);
int j =atoi(av[3]);
printf("%d %c %d\n",i,av[2][0],j);
//printf("%d %d %d\n","+","-","*");
int res=1;
if(av[2][0]=='+') res = i + j;
else if(av[2][0]=='-') res = i - j;
else if(av[2][0]=='*') res = i * j;
else if(av[2][0]=='/') res = i / j;
printf("%d\n +++++++++++++++++++++++\n",res);
putnbr(res);
return 0;
}