当前位置:网站首页>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;
}
边栏推荐
- 表的创建、修改与删除
- Secondary development of WinForm controls
- 接口测试实战| GET/POST 请求区别详解
- 2022暑假牛客多校联赛第一场
- Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
- DDL操作数据库、表、列
- 刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
- 2022/08/02 学习笔记 (day22) 多线程
- rosbag工具plotjuggler无法打开rosbag的问题
- UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
猜你喜欢

【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability

shell脚本循环语句

社交电商:链动2+1模式,为什么能在电商行业生存那么久?

在树莓派上搭建属于自己的网页(2)

js实现一个 bind 函数

Install PostgreSQL on Windows

Ali cloud object storage oss private barrels to generate links

typescript39-class类的可见修饰符

修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔

Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
随机推荐
Get the Ip tool class
Kotlin-Flow常用封装类:StateFlow的使用
建立树形结构
社交电商:链动2+1模式,为什么能在电商行业生存那么久?
Flink state
【Harmony OS】【FAQ】鸿蒙问题合集1
接口测试实战| GET/POST 请求区别详解
软件开发的最大的区别是什么?
BIOTIN ALKYNE CAS: 773888-45-2 Price, Supplier
CAD有生僻字如何打出来、如何提交软件相关问题或建议?
typescript49-交叉类型
Interface Test Framework Practice (4) | Get Schema Assertion
数据库基本概述与SQL概述
unity2D横板游戏教程6-敌人AI以及受击动画
UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
【生物素叠氮化物|cas:908007-17-0】价格_厂家
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
内部类、static关键字、final
DFS对剪枝的补充
typescript45-接口之间的兼容性