给华氏度计算摄氏度
#include
'int main() { double f; scanf("%lf", &f); printf("fahrenheit=%.6lf, celsius=%.6lf", f, (f - 32) *5 / 9); } 运行
给出摄氏度计算华氏度
#include
int main()
{
double c;
scanf("%lf", &c);
printf("celsius=%.6lf, fahrenheit=%.6lf", c, c * 9 / 5 + 32);
}
输出各个类型所占内存大小
#include
'int main() { int a=sizeof(int); printf("%d\n",a); int b=sizeof(unsigned); printf("%d\n",b); int c=sizeof(char); printf("%d\n",c); int d=sizeof(short); printf("%d\n",d); int e=sizeof(long); printf("%d\n",e); int f=sizeof(long long); printf("%d\n",f); int g=sizeof(100); printf("%d\n",g); int h=sizeof(-100); printf("%d\n",h); int i=sizeof(12345u); printf("%d\n",i); int j=sizeof(12345L); printf("%d\n",j); int k=sizeof(12345LL); printf("%d\n",k); int l=sizeof(1234567890); printf("%d\n",l); int m=sizeof(12345678900); printf("%d\n",m); int n=sizeof(0x12345670); printf("%d\n",n); int o=sizeof(0x1234567890); printf("%d\n",o); return 0; } 运行
输出不同类型最小表达和最大表达范围
#include
'#include int main() { printf("%d %d\n%d %d\n%d %u\n%d %d\n%lld %lld\n%llu %llu", CHAR_MIN, CHAR_MAX, INT_MIN, INT_MAX, 0, UINT_MAX, SHRT_MIN, SHRT_MAX, LLONG_MIN, LLONG_MAX, 0, ULLONG_MAX ); } 运行
计算对数
#include
#include
int main()
{
double base, real;
scanf("%lf %lf", &base, &real);
printf("%.6lf", log(real) / log(base));
return 0;
}