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
| #include <string.h>
int main(int argc, char *argv[])
{
int count;
int x;
int y;
int res;
char z[1];
count = 1;
x = atoi(argv[1]);
y = atoi(argv[3]);
if (argc < 3)
{
printf('\n');
return (0);
}
strcpy(z,argv[2]);
if (!strcmp(z,"+"))
{
res = x + y;
printf("%d", res);
}
strcpy(z,argv[2]);
if (!strcmp(z,"-"))
{
res = x - y;
printf("%d", res);
}
strcpy(z,argv[2]);
if (!strcmp(z,"*"))
{
res = x * y;
printf("%d", res);
}
strcpy(z,argv[2]);
if (!strcmp(z,"/"))
{
res = x / y;
printf("%d", res);
}
} |
Partager