- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
I'm trying to develop a C program that calculates the resistor values by inputting the colour bands marked on the resistor.
忽略电阻公差这是我的代码 输出必须类似于 Calculating the resistor value with its color bands as input
我下面的代码没有给我想要的东西。我希望它能够循环返回 y 和 no。输出必须分开 {3}{3}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
int bandChoice;
char colorOne[10];
char colorTwo[10];
char colorThree[10];
float codeOne;
float codeTwo;
float codeThree;
float x;
void colorCodes();
void multiplier();
void color_code(char codeOne);
int main(void)
{ printf("Enter the colors of the resistor three bands, beginning with the band nearest the end. Type the colors in lowercase letters only, NO CAPS\n");
puts(" ");
printf("Band 1 = >");
scanf("%s",colorOne);
puts(" ");
printf("Band 2 = >");
scanf("%s",colorTwo);
puts(" ");
printf("Band 3 = >");
scanf("%s",colorThree);
puts(" ");
printf("%f %f %f\n",colorOne,colorTwo,colorThree);
x=(codeOne*10)+codeTwo;
printf("Resistance value %d");
}
void color_code(char codeOne )
{
if(strcmp(colorOne, "black") == 0)
{
codeOne=0;
}
else
if(strcmp(colorOne, "brown") == 0)
{
codeOne=1;
}
else
if(strcmp(colorOne, "red") == 0)
{
codeOne=2;
}
else
if (strcmp(colorOne, "orange") == 0)
{
codeOne=3;
}
else
if (strcmp(colorOne, "yellow") == 0)
{
codeOne=4;
}
else
if (strcmp(colorOne, "green") == 0)
{enter code here
codeOne=5;
} else
if (strcmp(colorOne, "blue") == 0)
{
codeOne=6;
} else
if (strcmp(colorOne, "violet") == 0)
{
codeOne=7;
} else
if (strcmp(colorOne, "gray") == 0)
{
codeOne=8;
} else
if (strcmp(colorOne, "white") == 0)
{
codeOne=9;
} else
{
printf("Invalid colors\n");
}
}
void multiplier()
{
if(strcmp(colorThree, "black") == 0)
{
codeThree=1;
} else
if(strcmp(colorThree, "brown") == 0)
{
codeThree=10;
} else
if(strcmp(colorThree, "red") == 0)
{
codeThree=pow(10.0,2);
} else
if (strcmp(colorThree, "orange") == 0)
{
codeThree=pow(10.0,3);
} else
if (strcmp(colorThree, "yellow") == 0)
{
codeThree=pow(10.0,4);
} else
if (strcmp(colorThree, "green") == 0)
{
codeThree=pow(10.0,5);
} else
if (strcmp(colorThree, "blue") == 0)
{
codeThree=pow(10.0,6);
} else
if (strcmp(colorThree, "violet") == 0)
{
codeThree=pow(10.0,7);
} else
if (strcmp(colorThree, "gray") == 0)
{
codeThree=pow(10.0,8);
} else
if (strcmp(colorThree, "white") == 0)
{
codeThree=pow(10.0,9);
} else
{
printf("Invalid colors\n");
}
}
http://imgur.com/rya9egk
如果有人能提供帮助,我将不胜感激
最佳答案
color_code
函数设计不当。您应该将颜色字符串作为输入并返回代码字符串。.
char color_code(char *colorOne )
{
char codeOne;
if(strcmp(colorOne, "black") == 0)
{
codeOne=0;
}
// and so on for other colors
// at the end
return codeOne;
}
color_code
函数.
codeOne = color_code(colorOne);
您还需要对其他三个函数重复此操作。
变量 colorOne
colorTwo
colorthree
codeOne
codeTwo
codeThree
可以在 main 本地,而不是全局。
关于计算电阻值的色带并输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37382514/
我在 iPhone 上遇到了 openGL 问题,我确信一定有一个简单的解决方案! 当我加载纹理并显示它时,我得到了很多我认为所谓的“色带”,其中颜色,特别是渐变上的颜色,似乎会自动“优化”。 只是为
Android Activity 或 OpenGl 中出现 strip 图像的可能解决方案是什么。 请看下面的答案。 希望对你有帮助 最佳答案 色带已解决 ooooooooooyyyyyyyeaaaa
我有一个 working 'css ribbon tag' 但是,HTML 非常丑陋:
我想创建像这张图片(图片的红色部分)一样的丝带效果: 当我尝试创建带边框的箭头效果时,对象的形状完全被破坏了: HTML代码: Kategorija 到目前为止的 CSS 代码(没有尝试创建箭头):
在应用于正在进行的应用程序之前,我正在试验一些奇特的 CSS 效果,我遇到了 Ribbons . 就其本身而言,它工作得很好,但我不会按照生成器的建议使用固定元素,所以我在主框中添加了一个图像 但是,
我正在尝试使用 ggplot2 绘制热图,并且我想调整颜色栏的大小并增加字体。 这是代码的相关部分: g <- ggplot(data=melt.m) g2 <- g+geom_rect(aes(xm
一段时间以来,我一直在使用 this创建 Angular 丝带,到目前为止它一直运行良好: body { margin: 10% } img { border-radius: 0.5vw; }
我尝试创建 MS 功能区按钮图标表单代码。我创建了 32 bpp 的 CImage。 CImage img; img.Create(size, size, 32, CImage::createAlph
我有一个很大的表格,需要将单元格的背景更改为 1 到 6 个色带,就像矩形堆叠在一起(其他信息将出现在单元格内)。虽然这个例子是一个表格,但我猜这适用于任何 DIV。我希望能够(通过动态 javasc
我正在尝试反转这个朝阳可视化的色带。它使用带有标签等的 sunburst 可缩放图表。通常情况下,您只需反转它们正在使用的范围内的值,但我不太明白它是如何在设置中获取这些值的。 这是我使用的配色方案
我是一名优秀的程序员,十分优秀!