c语言程序设计试题

2024-11-26 16:36:51
推荐回答(3个)
回答1:

#include
using namespace std;
int main()
{
double weekprice,dol,cent,time;
cout<<"请输入一周薪水"< cin>>weekprice;
fflush(stdin);
cout<<"请输入工作时间"< cin>>time;
if(weekprice/time==0)
{
cent=(int)(weekprice*10.0/time);
cout<<"Your average hourly pay rate is 0 dollars and"< return 0;
}
else
{
dol=(int)(weekprice/time);
cent=(int)((weekprice-dol*time)*10.0/time);
cout<<"Your average hourly pay rate is "< return 0;
}

}

回答2:

#include
using namespace std;
int main()
{
double weekSalary,workingTime;
int dol,cent;
do
{
cout<<"请输入一周薪水,输入须为数值且不小于零,单位为“美元”)"<cin>>weekSalary;
}while(weekSalary<0)
do
{
cout<<"请输入工作时间,输入须为数值且大于0.0小于168.0,单位为“小时”)"<cin>>workingTime;
}while(workingTime<=0)
if(weekprice/workingTime==0)
{
cent=(int)(weekSalary*10.0/workingTime);
cout<<"Your average hourly pay rate is 0 dollars and"<}
else
{
dol=(int)(weekSalary/workingTime);
cent=(int)((weekSalary-dol*workingTime)*10.0/wokingTime);
cout<<"Your average hourly pay rate is "<}
return 0;

}

回答3:

#include
main()
{
float dollar;
float hour;
float a;
float b;
float c;
printf("your salary is:");
scanf("%f,&dollar);
printf("working hour:");
scanf("%f,&hour);
a=dollar/hour;
b=a-(int)a;
c=a-b;
printf("your average hourly pay rate is %.0f dollars and %.0f cents",c,100*b);
return 0;
}