4.编写程序,输入一个美元数量,然后显示出增加5%税率后的相关金额。
#include <cstdio>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main()
{
double a,b;
printf("Enter an amount: ");
scanf("%lf",&a);
printf("\nWith tax added: $%.2lf\n",a*1.05);
system("PAUSE");
return 0;
}
5.输入x,求出3*x^5+2*x^4-5*x^3-x^2+7*x-6的值
#include <cstdio>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main()
{
double x,y;
scanf("%lf",&x);
y=3*pow(x,5)+2*pow(x,4)-5*pow(x,3)-pow(x,2)+7*x-6;
printf("%lf\n",y);
system("PAUSE");
return 0;
}
7.编写一个程序,要求用户输入一个美金数量,然后显示出如何用最少的20美元、10美元、5美元、1美元来付款。
#include <cstdio>