作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
基本上,它要求“输入两组...”的部分循环两次,我只希望在做出这两个决定后运行一次。请注意,我还没有编写用于决定输入一个带有保留的评级的代码。这是 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", ¤t1);
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/
Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想改善这个问题吗?更新问题,以便将其作为on-topic
我正在尝试使用 plumbum 在 python 中执行以下命令: sort -u -f -t$'\t' -k1,1 file1 > file2 但是,我在传递 -t$'\t' 参数时遇到问题。这是我
这个程序给了我们奇数在给定整数中的位置,这个程序运行良好,但是当我给他一个整数时,它的数字大于 10 - 比如 123456789123-,它不起作用。不知道是内存问题还是算法问题? #include
我是一名优秀的程序员,十分优秀!