#include<stdio.h>
int amount[] = { 1,5,10,25,50 };
const char *name[] = { "penny","nickel","dime","quarter","half-doller" };
int search(int key, int a[], int len)
{
int ret = -1;
int i;
for (i = 0; i < len; i++)
{
if (key == a[i])
{
ret = i;
break;
}
}
return ret;
}
int main()
{
int k = 13;
int r = search(k, amount, sizeof(amount) / sizeof(amount[0]));
if (r != -1)
{
printf("%s\n", name[r]);
}
else
{
printf("找不到对应的值!\n");
}
return 0;
}