printf用法
格式
printf("要输出数的类型,输出的变量")
整数用%d
,小数用%lf
,要保留几位小数就在百分号后面写点几,char
类型用%s
。
练习
P5706 【深基2.例8】再分肥宅水
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argy)
{
double a;
int b;
cin>>a>>b;
printf("%.3lf\n%d",a/b*1.0,b*2);
return 0;
}