为什么n的值总是0呢,不理解
查看原帖
为什么n的值总是0呢,不理解
274607
070714zyz楼主2022/6/23 17:33

为什么我用scanf时n输入后总是0

#include <bits/stdc++.h>
using namespace std;

double n;
int t;

int main() {
	scanf("%f %d",&n,&t);
	printf("%.3f\n%d",n/t,2*t);
	return 0;
}

但是用cin就好好的

#include <bits/stdc++.h>
using namespace std;

double n;
int t;

int main() {
	cin>>n>>t;
	cout<<setprecision(3)<<fixed<<n/t<<endl<<t*2;
	return 0;
}

难道是人品问题???QAQ 求助各方大佬 谢谢了

2022/6/23 17:33
加载中...