我正在编写一个基本程序来使用C命令行参数计算算术几何平均值.但是程序似乎没有识别我输入的任何内容.这是我的代码:
/*
*This program will calculate an arithmetic-geometric mean
*provided two numbers (x,y) and an epsilon (e) are entered.
*/
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
int main (int argc, char **argv) {
//Check for command line argument.
if (argc != 4) {
printf ("Please enter two numbers (x,y) and an epsilon (e)\n");
printf ("as command line arguments for an AGM calculation\n");
exit(1);
}
double e,x,y,an,gn;
x = atof (argv[1]); //First number x.
y = atof (argv[2]); //Second number y.
e = atof …Run Code Online (Sandbox Code Playgroud)