k我被要求編寫一個函數sumArrayAscii,它接受一個字符串數組並返回該數組中所有字符串中所有字符的所有ASCII值的總和。請注意,這個函數應該使用sumAscii來解決問題。這是我,但我不能讓它TI工作sum Array Ascii接受一個字符串數組並返回該數組中所有字符串中所有字符的所有ascii值之和
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int myArrayNumberOfElements(5);
double myArray[myArrayNumberOfElements] = {1.1, 4.5, 5.7, 7.9, 10};
double sum(0);
for (int i(0); i < myArrayNumberOfElements; i++)
{
sum +=myArray[i];
}
cout << endl << "Sum of all elements: " << sum << endl;
system("PAUSE");
return 0;
到目前爲止,你的'sumArrayAscii'函數在哪裏?你有什麼嘗試? – twain249 2012-04-23 03:52:37
你想要的ASCII值的總和,還是你想將字符串轉換爲數字,並加起來這些數字? – 2012-04-23 03:57:58
什麼可行?什麼不?你生成了什麼測試輸入和輸出? – sarnold 2012-04-23 03:58:18