点击查看代码
#include <stdio.h>
int main(void)
{
int length, width, height;
float volume, weight;
printf("Length:%d\n", length);
printf("Width:%d\n", width);
printf("Height:%d\n", height);
printf("Volume:%f\n", volume);
printf("Weight:%.2f\n", weight);
return 0;
}
点击查看代码
#include <stdio.h>
int main(void)
{
int amount, twentyDollar, tenDollar, fiveDollar;
printf("请输入金额:");
scanf("%d", &amount);
printf("20美元数量:%d\n", amount / 20);
twentyDollar = amount / 20;
printf("10美元数量:%d\n", (amount - twentyDollar * 20) / 10);
tenDollar = (amount - twentyDollar * 20) / 10;
printf("5美元数量:%d\n", (amount - twentyDollar * 20 - tenDollar * 10) / 5);
fiveDollar = (amount - twentyDollar * 20 - tenDollar * 10) / 5;
printf("1美元数量:%d\n", amount - twentyDollar * 20 - tenDollar * 10 - fiveDollar * 5);
return 0;
}
点击查看代码
// 将华氏温度转换为摄氏温度
// 华氏温度 = 摄氏温度 * 9 / 5 + 32
#include <stdio.h>
#define FREEZING_PT 32.0f
#define SCALE_FACTOR (5.0f / 9.0f)
int main(void)
{
float fahrenheit, celsius;
printf("请输入华氏温度:");
scanf("%f", &fahrenheit);
celsius = (fahrenheit - FREEZING_PT) * SCALE_FACTOR;
printf("摄氏温度为:%.1f\n", celsius);
return 0;
}
点击查看代码
#include <stdio.h>
int main(void)
{
int length = 8, width = 10, height = 12, volume;
volume = length * width * height;
printf("面积计算:%d*%d*%d\n", length, width, height);
printf("面积为:%d\n", volume);
printf("体积重量为:%d\n", (volume + 165) / 166);
return 0;
}
点击查看代码
#include <stdio.h>
#define TAX 0.05f
int main(void)
{
float amount, taxAdded;
printf("请输入金额:", amount);
scanf("%f", &amount);
taxAdded = amount + amount * TAX;
printf("税后应付:%.2f\n", taxAdded);
return 0;
}
//int main(void)
//{
// float amount, taxAdded;
// printf("请输入金额:", amount);
// scanf("%f", &amount);
// taxAdded = amount * 1.05f;
// printf("税后应付:%.2f\n", taxAdded);
// return 0;
//}
点击查看代码
#include <stdio.h>
int main(void)
{
printf(" *\n");
printf(" *\n");
printf(" *\n");
printf("* *\n");
printf(" * *\n");
printf(" *\n");
return 0;
}
点击查看代码
//#include <stdio.h>
//int main(void)
//{
// int radius = 10;
// float volume = 4.0f / 3.0f * 3.14 * radius * radius * radius;
// printf("球的体积为:%.1f\n", volume);
// return 0;
//}
#include <stdio.h>
int main(void)
{
int radius;
printf("请输入半径:");
scanf("%d", &radius);
float volume = 4.0f / 3.0f * 3.14 * radius * radius * radius;
printf("体积为:%.1f", volume);
return 0;
}
点击查看代码
#include <stdio.h>
#define INCHES_PER_POUND 166
int main(void)
{
int length, width, height, volume, weight;
printf("请输入长度:");
scanf("%d", &length);
printf("请输入宽度:");
scanf("%d", &width);
printf("请输入高度:");
scanf("%d", &height);
volume = length * width * height;
weight = (volume + INCHES_PER_POUND - 1) / 166;
printf("体积为:%d\n", volume);
printf("体积重量为:%d\n", weight);
return 0;
}