当前位置:网站首页>1069 微博转发抽奖 (20 分)(C语言)
1069 微博转发抽奖 (20 分)(C语言)
2022-08-03 05:09:00 【破烂摆烂人】
小明 PAT 考了满分,高兴之余决定发起微博转发抽奖活动,从转发的网友中按顺序每隔 N 个人就发出一个红包。请你编写程序帮助他确定中奖名单。
输入格式:
输入第一行给出三个正整数 M(≤ 1000)、N 和 S,分别是转发的总量、小明决定的中奖间隔、以及第一位中奖者的序号(编号从 1 开始)。随后 M 行,顺序给出转发微博的网友的昵称(不超过 20 个字符、不包含空格回车的非空字符串)。
注意:可能有人转发多次,但不能中奖多次。所以如果处于当前中奖位置的网友已经中过奖,则跳过他顺次取下一位。
输出格式:
按照输入的顺序输出中奖名单,每个昵称占一行。如果没有人中奖,则输出 Keep going…。
输入样例 1:
9 3 2
Imgonnawin!
PickMe
PickMeMeMeee
LookHere
Imgonnawin!
TryAgainAgain
TryAgainAgain
Imgonnawin!
TryAgainAgain
输出样例 1:
PickMe
Imgonnawin!
TryAgainAgain
输入样例 2:
2 3 5
Imgonnawin!
PickMe
输出样例 2:
Keep going...
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int m , n , s ;
scanf("%d %d %d",&m,&n,&s) ;
char name[1000][21] , line[21] ;
int cnt = 0 , r = 0 ;
int i , j ;
for( i = 0 ; i < m ; i++ ){
scanf("%s",&line) ;
if( i == s-1+cnt*n+r ){
int flag = 1;
for( j = 0 ; j < cnt ; j++ ){
if(strcmp(name[j],line)==0){
flag = 0;
r++ ;
break;
}
}
if(flag==1){
strcpy(name[cnt],line) ;
cnt++ ;
}
}
}
if(!cnt){
printf("Keep going...") ;
}else{
for( i = 0 ; i < cnt ; i++ ){
printf("%s\n",name[i]) ;
}
}
return 0;
}
边栏推荐
- OSI的分层特点、传输过程与三次握手、四次挥手、tcp与udp包头的描述
- 【Harmony OS】【ARK UI】ets use startAbility or startAbilityForResult to invoke Ability
- MCM box model modeling method and source analysis of atmospheric O3
- [Harmony OS] [ArkUI] ets development graphics and animation drawing
- 【生物素叠氮化物|cas:908007-17-0】价格_厂家
- 【Harmony OS】【ARK UI】轻量级数据存储
- Online password generator tool recommendation
- 荧光标记多肽FITC/AMC/FAM/Rhodamine/TAMRA/Cy3/Cy5/Cy7-Peptide
- typescript45-接口之间的兼容性
- Power button 561. An array of split
猜你喜欢
超好用的画图工具推荐
修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔
探索性测试的概念及方法
Ali cloud object storage oss private barrels to generate links
Alienware上线首个数字时装AR试穿体验
Super handy drawing tool is recommended
typescript43-类型兼容性说明
【生物素叠氮化物|cas:908007-17-0】价格_厂家
js实现一个 bind 函数
Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
随机推荐
【Harmony OS】【ARK UI】ets use startAbility or startAbilityForResult to invoke Ability
修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔
DFS's complement to pruning
typescript49-交叉类型
Tag stack - stack monotonically preparatory knowledge - lt. 739. The daily temperature
idea使用@Autowired注解爆红原因及解决方法
接口管理工具YApi怎么用?颜值高、易管理、超好用
Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
【HMS core】【Ads Kit】华为广告——海外应用在国内测试正式广告无法展示
[Fine talk] Using native js to implement todolist
移动流量的爆发式增长,社交电商如何选择商业模式
【生物素叠氮化物|cas:908007-17-0】价格_厂家
c语言结构体中的冒泡排序
自组织是管理者和成员的双向奔赴
在树莓派上搭建属于自己的网页(2)
typescript42-readonly修饰符
JS底层手写
技术分享 | 接口自动化测试中如何对xml 格式做断言验证?
Build your own web page on the Raspberry Pi (2)
Windows 安装PostgreSQL