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