【发布时间】:2014-02-18 01:45:15
【问题描述】:
值 K 设置为根据 i 递增,以便评估 l1、l2、l3、l4 直到 k
#include <stdio.h>
#include <math.h>
int main(void) {
float c=0, h=0, x=0, i=0;
printf("Proj. #2 - Juan Perez\n");
printf("Power of lamps (in watts)? ");
scanf("%f" , &c);
printf("Height of lamp (in meters)? ");
scanf("%f" , &h);
printf("Distance apart? (in meters)? ");
scanf("%f" , &x);
printf("Interval? (in meters)? ");
scanf("%f" , &i);
printf("Power: %f\n", c);
printf("Height: %f\n", h);
printf("Distance apart: %f\n", x);
printf("Interval: %f\n", i);
float k=75, d=0, e=x, f=2*x, g=3*x;
float l1=((c*h)/(powf((h*h)+((k-d)*(k-d)), 1.5)));
float l2=((c*h)/(powf((h*h)+((k-e)*(k-e)), 1.5)));
float l3=((c*h)/(powf((h*h)+((k-f)*(k-f)), 1.5)));
float l4=((c*h)/(powf((h*h)+((k-g)*(k-g)), 1.5)));
float j=l1+l2+l3+l4;
while (k<=g){
printf("%f\n", j);
k+=i;
}
}
【问题讨论】:
-
你说“直到 k
标签: c loops while-loop