Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- int main(int argc, char* argv[]) {
- if (argc != 3) {
- printf("Usage: exp <start> <end>\n");
- return 1;
- }
- int start = atoi(argv[1]);
- int end = atoi(argv[2]);
- if (start > end) {
- printf("The start value must be lower than the end value");
- return 1;
- }
- // On lance pari GP
- FILE* gp;
- char path[1035];
- gp = popen("echo 'forstep(i=0, 2, 0.1, print(exp(i)))\nquit\n' | /usr/bin/gp -q", "r");
- if (gp == NULL) {
- printf("GP n'est pas installé sur la machine\n");
- exit(1);
- }
- long double i = 0;
- while (fgets(path, sizeof(path)-1, gp) != NULL) {
- long double n = exp(i);
- printf("GP = %s", path);
- printf("C = %.20Lf\n", n);
- i += 0.1;
- }
- // printf("%s\n", system("\\p 128\nforstep(i=1, 1000, 0.1, print(i \"=\" ${fn}(i)))\nquit\n"));
- pclose(gp);
- /*
- for (double i = (double)start ; i <= end ; i++) {
- printf("exp(%d)=%d", i, exp(i));
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement