gpt4 book ai didi

c - 铅电池实验室 - 普克特定律

转载 作者:行者123 更新时间:2023-11-30 18:31:38 25 4
gpt4 key购买 nike

基本上,它要求“输入两组...”的部分循环两次,我只希望在做出这两个决定后运行一次。请注意,我还没有编写用于决定输入一个带有保留的评级的代码。这是 C 语言编程。

#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<conio.h>

int main()
{
double current1;
double current2;
double capacity1;
double capacity2;
double time1;
double time2;
double exponent1;
double exponent2;
double counter;
double ampereh1;
double ampereh2;
double decision;
double c1,c2,r1,r2;
double reserve;
double limit;
double decision2;
double decision3;

printf("Lead Acid Battery - Peukert's Law\n\nThis program allows for the user to input battery specs and calculate\nvalues from peukert's variables.\n");

printf("\nSelect an increment value: "); /*User will input how much the initial value will increase by for each row in the column calculated*/
scanf("%lf", &counter);
printf("What format would you like?\n(Format 1: Press 1, Format 2: Press 2): "); /*Format 1 describes input of current, Format 2 describes input of time*/
scanf("%lf", &decision);

if (decision == 1)
{
printf("Two ratings or one rating w/ reserve (Press 1/2): ");
scanf("%lf", &decision2);
}

if (decision2 == 1);
{
printf("Input two sets of hourly rate capacity (hours) then ah capacity (ampere hours):\n"); /*User will input each set of r capacity and ah capacity*/
scanf("%lf %lf %lf %lf", &r1, &c1, &r2, &c2);
printf("Input reserve capacity (mins): ");
scanf("%lf", &reserve);
exponent1 = (log(r2/r1))/(log(c1/r1)-log(c2/r2));
capacity1 = r1 * pow((c1/r1),exponent1);
printf("Select initial Electrical Current value: "); /*User can choose any initial value to start from in row one within the table*/
scanf("%lf", &current1);
printf("Maximum value of electrical current to calculate until: ");
scanf("%lf", &limit); /*User can choose the maxiumum value on the table of the initial value to increase to*/
printf("Electrical\tDischarge\tAh\n");
printf("Current\t\tTime\t\tCapacity\n");


for (current1;current1<=limit;current1+=counter)
{ /*Will loop until table is finished up to the limit's maxiumum value that the user inputed*/

time1 = capacity1/pow(current1,exponent1);
ampereh1 = current1*time1;
printf("%lf\t%lf\t%lf\n", current1, time1, ampereh1);

}
printf("Peukert's Exponent: %lf\n", exponent1);
printf("Reserve Capacity (minutes): %lf\n", reserve);
}

if (decision == 2)
{
printf("Two ratings or one rating w/ reserve (Press 1/2): ");
scanf("%lf", &decision3);
}

if (decision3 == 1);
{
printf("Input two sets of hourly rate (hours) and then capacity (ampere hours):\n");
scanf("%lf %lf %lf %lf", &r1, &c1, &r2, &c2);
printf("Input reserve capacity (mins): ");
scanf("%lf", &reserve);
exponent2 = (log(r2/r1))/(log(c1/r1)-log(c2/r2));
capacity2 = r1 * pow((c1/r1),exponent2);
printf("Select initial Time value: ");
scanf("%lf", &time2);
printf("Maximum value of time to calculate until: ");
scanf("%lf", &limit);
printf("Discharge\tElectric\tAh\n");
printf("Time\t\tCurrent\t\tCapacity\n");

for(time2;time2<=limit;time2+=counter){
current2 = pow(capacity2/time2,1/exponent2);
ampereh2 = current2*time2;
printf("%lf\t%lf\t%lf\n", time2, current2, ampereh2);
}

printf("Peukert's Exponent: %lf\n", exponent2);
printf("Reserve Capacity (minutes): %lf\n", reserve);
}

system("Pause");
return(0);
}

最佳答案

您的某些 if 语句不起作用,例如,

if (决策2 == 1);{

if (决策3 == 1);{

它实际上的工作原理就像

if (decision2 == 1){
}

{
// your code here

关于c - 铅电池实验室 - 普克特定律,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21387511/

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