gpt4 book ai didi

c++ - 将 stdio.h 程序转换为 iostream

转载 作者:太空宇宙 更新时间:2023-11-04 04:59:43 24 4
gpt4 key购买 nike

<分区>

这是我的主要模块。我有一些外部模块。

int main(void)
{
char ln[15+1];
char fn[10+1];
float fed,state,ssi;
float g,h,p,d,n;

InputEmployeeData(&ln[0],&fn[0],&h,&p,&d); // call 3.3
CalculateGross(h,p, &g); // call 3.4
computeTaxes(g,d,ADDR(fed),ADDR(state),ADDR(ssi)); // call 3.5
n = g-fed-state-ssi-d;
printf(" Fed = %8.2f\n",fed);
printf(" State = %8.2f\n",state);
printf(" SSI = %8.2f\n",ssi);
printf(" Net = %8.2f\n",n);
while(getchar() != '\n'); // flush(stdin)
return 0;

使用 iostream 的 main.cpp

cout << "  Fed   =   %8.2f\n" << fed;
cout << " State = %8.2f\n" << state;
cout << " SSI = %8.2f\n" << ssi;
cout << " Net = %8.2f\n" << n;
cin.sync();
//while(getchar() != '\n');
// flush(stdin)
return 0;

使用 stdio.h 输入 putemployeedata.cpp

//3.3
#include <stdio.h>
#define ADDR(var) &var

void InputEmployeeData(char *lastname,char *firstname, // 3.3
float *hours,float *payrate, float *defr);

void InputEmployeeData(char *lastname,char *firstname, // 3.3
float *hours,float *payrate, float *defr)
{
printf(" Enter the name ==> ");
scanf("%s%s",firstname,lastname);
printf(" Enter the hours and payrate ==> ");
scanf("%f%f",hours,payrate);
printf(" Enter the deferred earning amount ==> ");
scanf("%f",defr);
}

使用 iostream 的 inputemployeedata.cpp

{
cout << " Enter the name ==> ";
cin >> *firstname >> *lastname;
cout <<" Enter the hours and payrate ==> ";
cin >> *hours >> *payrate;
cout << " Enter the deferred earning amount ==> ";
cin >> *defr;

我不知道 cout%8.2f 等价物。我只是卡住了 enter image description here

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com