我的代码是这样的:
#include <cstdio>
using namespace std;
int main(){
double t;
int n;
scanf('%lf%d',&t,&n);
printf('%.3f\n%d', t/n, n * 2);
return 0;
}
和《深基》上的一样
然而即使我使用cin
,开double,还是会爆:
/tmp/compiler_0u06s91u/src:7:11: 警告:字符常量大小超出其类型
scanf('%lf%d',&t,&n);
^~~~~~~
/tmp/compiler_0u06s91u/src:8:12: 警告:字符常量大小超出其类型
printf('%.3f\n%d', t/n, n * 2);
^~~~~~~~~~
/tmp/compiler_0u06s91u/src: 在函数‘int main()’中:
/tmp/compiler_0u06s91u/src:7:11: 错误:invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
scanf('%lf%d',&t,&n);
^~~~~~~
......