[ create a new paste ] login | about

Link: http://codepad.org/gbkDS7bZ    [ raw code | output | fork ]

C++, pasted on Jun 4:
#include <string>
#include <iostream>
using namespace std;

int get_index(string number)
{
	int index = 0;
	string pNUM[] = 
	{"zero","one","two","three","four","five","six","seven","eight","nine",""};
	for(index = 0; pNUM[index].length(); index++)
	{
		if(number == pNUM[index])
			break;
	}
	return index;
}

int main()
{
	cout<<get_index("two")<<endl;
	return 0;
}


Output:
1
2


Create a new paste based on this one


Comments: