为什么C没有从结构中获取价值
Why C is not taking value from structure?
我创建了结构并给出了负载C和G的值。我希望用户输入荷载,它必须与结构中的荷载之一匹配。然后,应取相应负载的C和G值进行进一步计算。我的问题是,每当我输入例如 1 的负载时,它必须将 C 的值作为 38,而是需要2293652。即使我输入其他负载值,它仍然需要相同的值。我来自机械背景,所以不要对我太苛刻
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
using namespace std;
struct hook{
float SL;
int C;
int G;
};
struct hook h[]={
{0.5, 27, 14},
{1, 38, 20},
{2, 53, 27},
{3.2, 68, 35},
{5, 85, 42},
{8, 107, 55},
{10, 119, 60},
{12, 134, 68},
{16, 151, 76},
{20, 169, 80},
{25, 189, 90},
{32, 207, 100}
};
int main()
{
float SL1;
int C1, G1;
cout << "Enter the safe working load:n" << endl;
cin >> SL1;
int i;
i >=0;
for (i=0; i < sizeof h /sizeof *h; i++){
if(h[i].SL == SL1){
h[i].C = C1;
h[i].G = G1;
break;
}
}
float H=0.93*C1, M=0.6*C1, Z=0.12*C1;
cout << C1 << endl;
return 0;
}
不应该这些"h[i]吗?C = C1;" 反过来??
看来这就是问题所在! :O
相关文章:
- 从字符串中获取结构的大小
- 获取结构 c++ 中元素的索引
- 如何获取结构C++的输入
- 使用加速融合获取结构名称
- 如何使用值获取结构的索引
- 如何获取结构体成员的地址
- 从行分析中获取结构
- 获取结构的 UUID
- 如何从 QMetaType 获取结构成员的名称
- 在发送/获取结构时使用 streambuf
- 无法获取结构 C# 的指针
- 如何在LLVM中获取结构成员的值?
- 如何从命名管道获取结构化数据并将其写入Qt中的qtableview
- 如何获取结构的元素作为类型提升::shared_ptr
- C++-如何获取结构的最后一个成员类型以及从现有对象访问它的方法
- 在c++中获取结构的参数名称
- 当我尝试获取结构成员的地址时,会发生奇怪的事情
- 获取结构数组 c++ 中的元素数
- 如何获取结构或类的尾随填充的大小
- 正在获取结构的实际大小