#include <stdio.h>
struct shouhin {
char code[4];
char name[20];
int price;
int number;
};
int main()
{
struct shouhin s[] = {
{"fm1", "フラッシュメモリ", 1500, 27},
{"hu2", "ハブ", 23000, 8},
{"mo3", "マウス", 2560, 12},
};
char code[4];
int i, num;
num = sizeof s / sizeof (struct shouhin);
for (i = 0; i < num; i++) {
if (strcmp(code
, s
[i
].
code) == 0) break; }
if (i < num) {
printf("商品コード 商品名 価格 販売数 販売額\n"); printf("-------------------------------------------------------------\n"); printf("%-3s %-19s %10d %10d %10d\n", s[i].code, s[i].name, s[i].price, s[i].number, s[i].price * s[i].number);
} else {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpzdHJ1Y3Qgc2hvdWhpbiB7CgljaGFyCWNvZGVbNF07CgljaGFyCW5hbWVbMjBdOwoJaW50CXByaWNlOwoJaW50CW51bWJlcjsKfTsKCmludCBtYWluKCkKewoJc3RydWN0IHNob3VoaW4gc1tdID0gewoJCXsiZm0xIiwgIuODleODqeODg+OCt+ODpeODoeODouODqiIsIDE1MDAsIDI3fSwKCQl7Imh1MiIsICLjg4/jg5YiLCAyMzAwMCwgOH0sCgkJeyJtbzMiLCAi44Oe44Km44K5IiwgMjU2MCwgMTJ9LAoJfTsKCWNoYXIJY29kZVs0XTsKCWludAlpLCBudW07CgoJcHJpbnRmKCLllYblk4HjgrPjg7zjg4njgpLlhaXlipvvvJpcbiIpOwoJc2NhbmYoIiUzcyIsIGNvZGUpOwoJbnVtID0gc2l6ZW9mIHMgLyBzaXplb2YgKHN0cnVjdCBzaG91aGluKTsKCWZvciAoaSA9IDA7IGkgPCBudW07IGkrKykgewoJCWlmIChzdHJjbXAoY29kZSwgc1tpXS5jb2RlKSA9PSAwKSBicmVhazsKCX0KCWlmIChpIDwgbnVtKSB7CgkJcHJpbnRmKCLllYblk4HjgrPjg7zjg4kg5ZWG5ZOB5ZCNICAgICAgICAgICAgICDkvqHmoLwgICAgICDosqnlo7LmlbAgICAg6LKp5aOy6aGNXG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