问题及代码:
/*
题目描述
某公司按周发放工资,标准是每小时制20元,若员工周
工作时间超过40小时,超出部分每小时30元。编程序输
入一名员工一周的工作小时数,输出他的周工资
例如输入32 输出640
输入48 输出1040
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b;
printf("员工一周的工作小时数:\n");
scanf("%d",&a);
if(a<=40)
b=20*a;
else
b=20*40+(a-40)*30;
printf("他的周工资为:%d\n",b);
return 0;
}
运算结果
<img src="https://img-blog.csdn.net/20161008081115159" alt="" />
<img src="https://img-blog.csdn.net/20161008081210051" alt="" />
知识点总结:通过这个实际问题让我们可以在实际生活中应用程序 让程序方便我们的生活
学习心得:写程序时要先写出框图列一个大致结构再写这样会省事很多