#include<bits/stdc++.h>
#include<iostream>
#include<iostream>
using namespace std;
int main(){
cout<<"bool\t"<<"占的字节数为:"<<sizeof(bool)<<endl;
cout<<"char\t"<<"占的字节数为:"<<sizeof(char)<<endl;
cout<<"int\t"<<"占的字节数为:"<<sizeof(int)<<endl;
cout<<"float\t"<<"占的字节数为:"<<sizeof(float)<<endl;
cout<<"double\t"<<"占的字节数为:"<<sizeof(double)<<endl;
return 0;
}
例题:
这个题目首先知道要用到“printf("%.2lf")”来输出2位小数
#include<iostream>
using namespace std;
int main(){
double a=3.1415926,r,b=0;
cin>>r;
b=2*a*r;
printf("%.2lf",b);
return 0;
}
这是最终的程序!