我必須得到由空格分隔的2位數字的字符串,以某種方式取出數字並對它們進行操作。但值都走錯了,親眼看到:給出奇怪值的字符串
...
string = "08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08"; //example
for (int i = 0; i < string.size()-2; i += 3){
arr[i] = 10 * string[i] + string[i+1];
cout << arr[i] <<' '<< 10 * string[i] <<' '<< string[i] << string[i+1] <<endl;
}
output:
536 480 08 i guess 0 times 10 isn't 480 as well as that plus 8 equals 536
530 480 02
550 500 22
625 570 97
566 510 38
543 490 15
528 480 00
568 520 40
528 480 00
603 550 75
532 480 04
533 480 05
535 480 07
606 550 78
580 530 52
540 490 12
578 530 50
605 550 77
619 570 91
536 480 08
什麼是'arr'?你是否想要對ascii字符值進行數學計算? –