比较来自世界各地的卖家的域名和 IT 服务价格

使用命令行实用程序中的用户输入 Objective-C Foundation

我正在尝试创建一个应用程序,解决命令行上的二次公式 Objective-C. 我的代码仍然是这样的:


#import <foundation foundation.h="">

int main /int argc, const char * argv[]/{

double a, b, c, sol1, sol2;

NSLog/@"Welcome to the quadratic solver"/;

NSLog/@"Please enter the value of a"/;
scanf/"%f", &amp;a/;

NSLog/@"Please enter the value of b"/;
scanf/"%f", &amp;b/;

NSLog/@"Please enter the value of c"/;
scanf/"%f", &amp;c/;

sol1 = /-b + sqrt/ /double/pow/b,2/ - 4 * a *c/ / / 2 * a;
sol2 = /-b - sqrt/ /double/pow/b,2/ - 4 * a *c/ / / 2 * a;

NSLog/@"If a is: %f, b is %f, and c is %f.", a, b, c/;

NSLog/@"Solution one is: %f", sol1/;
NSLog/@"Solution two is: %f", sol2/;


}

但我的输出没有收到任何信息。


2012-01-26 17:23:53.585 test[4595:707] Welcome to the quadratic solver
2012-01-26 17:23:53.588 test[4595:707] Please enter the value of a
1
2012-01-26 17:23:56.030 test[4595:707] Please enter the value of b
3
2012-01-26 17:23:56.558 test[4595:707] Please enter the value of c
-10
2012-01-26 17:23:58.670 test[4595:707] If a is: 0.000000, b is 0.000000, and c is 0.000000.
2012-01-26 17:23:58.672 test[4595:707] Solution one is: -0.000000
2012-01-26 17:23:58.672 test[4595:707] Solution two is: -0.000000


任何贡献都非常有价值!
</foundation>
已邀请:

三叔

赞同来自:

您有一个不一致的文本集...您扫描 %f,, 因此,您需要声明:


float a, b, c, sol1, sol2;


然后你的程序完美地在我的车上工作。

要回复问题请先登录注册