本文共 920 字,大约阅读时间需要 3 分钟。
考察查询表以及信息记录
#includechar g_CharTable[3] = {'W', 'T', 'L'};void CheckCharTable(){ int cnt = 3; for(int i = 0; i < cnt; ++i) printf("%c\n", g_CharTable[i]);}int main(){ //CheckCharTable(); float a[3][3]; while(scanf("%f%f%f", &a[0][0], &a[0][1], &a[0][2]) != EOF) { for(int i = 1; i < 3; ++i) scanf("%f%f%f", &a[i][0], &a[i][1], &a[i][2]); int maxIndex[3]; float maxValue[3]; //get max index & value for(int i = 0; i < 3; ++i) { float tmpMaxValue = a[i][0]; int tmpMaxIndex = 0; for(int j = 0; j < 3; ++j) { if(a[i][j] > tmpMaxValue) { tmpMaxValue = a[i][j]; tmpMaxIndex = j; } } maxIndex[i] = tmpMaxIndex; maxValue[i] = tmpMaxValue; } //get resut float ans = (maxValue[0]*maxValue[1]*maxValue[2]*0.65-1.0)*2.0; //output for(int i = 0; i < 3; ++i) printf("%c ", g_CharTable[maxIndex[i]]); //ans += 0.005;//up to 2 decimal places printf("%.2f\n", ans); } return 0;}
转载地址:http://taxti.baihongyu.com/