See, my blog!

Unexpected, I had the idea to get a blog of my own. It really scared me at first. How did it pop into my head? Is the fashion of writing blogs that makes me have such an impulse? Never. Or do I really need a log to track my life? In some way. Then do I want to share something with others and communicate with them? For sure. After visiting some blogs of my friends and those excellent blogs on the internet, I found it the very thing I need. Blog, is the place where I can share something with you, such as my emotions, my experiences, my ideas, and my dreams... Besides, I can communicate with you, exchanging views on everything. Have you got any idea about the importance of communication? Well, Communication makes understanding, progress, and miracles.
In my blog, I will record everything about me, except for my privacy. You can find how I feel the world, how I realize the world, and how I explore the world. The sole tool is my brain. The main theme is SOFTWARE, after all, it is my major and interest. You can also share with me your experiences, your lost, your gain; your joy, your pain... anything you would like to communicate. Remember, your comments are always welcome.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用C语言的哈希表(hash table)来实现这个功能。首先,我们定义一个结构体来表示机器人遇到的每个人: ```c typedef struct { int id; int count; char greeting[30]; } Person; ``` 然后,我们可以使用哈希表来存储遇到的人和对应的信息。我们可以使用一个数组来表示哈希表,数组的索引是人的编号,数组元素是Person结构体。例如,对于输入样例中的7个人,我们可以定义一个大小为100000的Person类型数组: ```c Person hashTable[100000]; ``` 接下来,我们可以编写一个函数来处理机器人遇到新人的情况,更新哈希表中的信息: ```c void processNewPerson(int id, char name[]) { if (hashTable[id].count == 0) { sprintf(hashTable[id].greeting, "Hello %s, how are you?", name); } else { sprintf(hashTable[id].greeting, "Hi %s! Glad to see you again!", name); } hashTable[id].count++; } ``` 最后,我们可以遍历输入的人的编号,并调用processNewPerson函数来处理每个人: ```c int main() { int N; scanf("%d", &N); for (int i = 0; i < N; i++) { int id; char name[6]; scanf("%d", &id); sprintf(name, "%.5d", id); processNewPerson(id, name); printf("%s\n", hashTable[id].greeting); } return 0; } ``` 这样,程序就可以根据输入的人的编号输出机器人的打招呼内容了。注意,为了保证输出的格式与样例一致,我们在输出之前先调用processNewPerson函数更新哈希表中的信息。 希望这个程序能满足您的要求!如果还有其他问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值