#include <stdio.h> struct{ int amount; char *name; } coins[] = { {1, "penny"}, {5, "nickel"}, {10, "dime"}, {25, "quarter"}, {50, "harf-doller"} }; int main(){ int k = 5; for (int i = 0; i < sizeof(coins)/sizeof(coins[0]); ++i) { if(k == coins[i].amount){ printf("%s\n",coins[i].name); } } return 0; }
标签:name,int,coins,浙大,amount,例子,搜索,sizeof From: https://www.cnblogs.com/xinrenbool/p/16955996.html