📄 ch5_7.c
字号:
/*ch5_7*/
#include<stdio.h>
main()
{
long profit;
int grade;
float salary=500;
printf("Input profit: ");
scanf("%ld", &profit);
grade= (profit - 1) / 1000;
/*将利润-1、再整除1000,转化成switch语句中的case标号*/
switch(grade)
{
case 0: break; /*profit≤1000 */
case 1: salary += profit*0.1; break; /*1000<profit≤2000 */
case 2:
case 3:
case 4: salary += profit*0.15; break; /*2000<profit≤5000 */
case 5:
case 6:
case 7:
case 8:
case 9: salary += profit*0.2; break; /*5000<profit≤10000 */
default: salary += profit*0.25; /*10000<profit */
}
printf("salary=%.2f\n", salary);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -