我正在努力使歐姆法律計劃。 V = IR。任何人都可以幫我用我的C代碼嗎?
#include <stdio.h>
int main(int argc, const char * argv[]) {
int V,I,R;
printf("please enter the value of the current if the value is not known make I=0 ");
scanf("%d", &I);
printf("please entre the value of the resistance if the value is not known make R=0");
scanf("%d", &R);
printf("please enter the value of the voltage, if unknown make V=0");
scanf("%d", &V);
if (V == 0)
V = I*R;
{
printf(" V = %d",V);
}
else if (I==0)
I = V/R;
{
printf("I = %d ",I);
}
else
R = V/I;
{
printf("R= %d",R);
}
return 0;
}
我是初學者,我該如何改進我的代碼,所以它的工作原理? 任何幫助如此讚賞謝謝。
歡迎使用stackoverflow。爲了幫助你,我們需要知道你的實際問題。你期望程序做什麼以及它做什麼? – Philipp
請閱讀[C tutorial](http:// www.tutorialspoint.com/cprogramm荷蘭國際集團/)。 – Gangadhar
這個問題似乎是無關緊要的,因爲它太侷限了。 –