我需要输入一个数据文件(如下):
14 16 18 20 22 24
27 30 35 40 45 50
8 10 11 12 13 14
16 18 21 24 27 30
0.4 0.5 0.5 0.5 0.5 0.5
0.6 0.6 0.6 0.6 0.6 0.6
16 17 18 19 20 21
22 23 25 26 27 29
2.0 2.2 2.2 2.3 2.4 2.5
2.6 2.7 2.8 2.9 3.1 3.2
1.7 1.8 2.0 2.2 2.4 2.5
2.8 3.0 3.4 3.8 3.8 3.8
在选择第一列时,将输出这些阀门。
这是我的代码;谁能看到任何错误?
void TimberType() {
ifstream inFile;
inFile.open("TableOfValues.txt", ios::in );
string TimberValues;
inFile >> TimberValues;
inFile >> bendStr >> tensPara >> tensPerp >> compPara >> compPerp >> shear >> mElasModPara >> elasMod5Para >> mElasModPerp >> mShearMod >> density >> mDensity;
cout << "Please enter timber type " << endl;
cout << "C14 = 1 C16 = 2 C18 = 3 C20 = 4" << endl;
cout << "C22 = 5 C24 = 6 C27 = 7 C30 = 8" << endl;
cout << "C35 = 9 C40 = 10 C45 = 11 C50 = 12" << endl;
cin >> timberType;
{
switch (timberType) {
case 1:
timberType = 1;
cout << "You have selected timber type C14" << endl;
cout << TimberValues[1];
break;
case 2:
timberType = 2;
cout << "You have selected timber type C16" << endl;
cout << TimberValues[2];
break;
case 3:
timberType = 3;
cout << "You have selected timber type C18" << endl;
cout << TimberValues[3];
break;
case 4:
timberType = 4;
cout << "You have selected timber type C20" << endl;
cout << TimberValues[4];
break;
case 5:
timberType = 5;
cout << "You have selected timber type C22" << endl;
cout << TimberValues[5];
break;
case 6:
timberType = 6;
cout << "You have selected timber type C24" << endl;
cout << TimberValues[6];
break;
case 7:
timberType = 7;
cout << "You have selected timber type C27" << endl;
cout << TimberValues[7];
break;
case 8:
timberType = 8;
cout << "You have selected timber type C30" << endl;
cout << TimberValues[8];
break;
case 9:
timberType = 9;
cout << "You have selected timber type C35" << endl;
cout << TimberValues[9];
break;
case 10:
timberType = 10;
cout << "You have selected timber type C40" << endl;
cout << TimberValues[10];
break;
case 11:
timberType = 11;
cout << "You have selected timber type C45" << endl;
cout << TimberValues[11];
break;
case 12:
timberType = 12;
cout << "You have selected timber type C50" << endl;
cout << TimberValues[12];
break;
}
cout << "Bending Strength: " << bendStr << "N/mm^2" << endl;
cout << "Tension in Parallel: " << tensPara << "N/mm^2" << endl;
cout << "Tension in Perpendicular: " << tensPerp << "N/mm^2" << endl;
cout << "Compression in Parallel: " << compPara << "N/mm^2" << endl;
cout << "Compression in Perpendicular: " << compPerp << "N/mm^2" << endl;
cout << "Shear: " << shear << "N/mm^2" << endl;
}
}
目前,我只收到 0 值的弯曲强度、平行张力、垂直张力、平行压缩、垂直压缩和剪切。
任何想法将不胜感激。谢谢你。