c 语言的计算(电阻)

来源:百度知道 编辑:UC知道 时间:2024/05/28 02:38:22
请问要如何用C计算电阻的三色环
如~~宗 黑 红 ==1K
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[])
{
char a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, j=0;
int x, y, z, p;
//explanation
printf("\nThis program is to calculate the roots of a quadratic equation.\n");
printf("a=宗 b=红 c=澄 d=黄 e=绿 f=蓝 g=紫 h=灰 i=白 j=黑\n");

//prompt for input
printf("Please choose the first colours you want:\n");
scanf(" %c", &x);
printf("Please choose the second colours you want:\n");
scanf(" %c", &y);
printf("Please choose the third colours you want:\n");
scanf(" %c", &z);
//calculation
p=(x*10+y)*pow(double(10),double(z));// 出现错误

下面是正文:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[])
{
char danwei[3]={'K','M','G'};
int i=-1; bool flag=false;
int x, y, z, p;
double pp;
//explanation
printf("\nThis program is to calculate the roots of a quadratic equation.\n");
printf("1=宗 2=红 3=澄 4=黄 5=绿 6=蓝 7=紫 8=灰 9=白 0=黑\n");

//prompt for input
printf("Please choose the first colours you want:\n");
scanf(" %d", &x);
printf("Please choose the second colours you want:\n");
scanf(" %d", &y);
printf("Please choose the third colours you want:\n");
scanf(" %d", &z);
//calculation
if(x<0 || x>9) { printf("input x error!"); return -1; }
if(y<0 || y>9) { printf("input y error!"); retur