当前位置:网站首页>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;
}
边栏推荐
- 高可用 两地三中心
- 社交电商如何做粉丝运营?云平台怎么选择商业模式?
- 2022/08/02 Study Notes (day22) Multithreading
- Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data
- Build your own web page on the Raspberry Pi (2)
- Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
- 【Harmony OS】【FAQ】Hongmeng Questions Collection 1
- Get the Ip tool class
- 链动2+1模式简单,奖励结构丰厚,自主裂变?
- CobalStrike(CS)基础超级详细版
猜你喜欢
tag单调栈-单调栈预备知识-lt.739. 每日温度
「短视频+社交电商」营销模式爆发式发展,带来的好处有什么?
测试人员的价值体现在哪里
接口管理工具YApi怎么用?颜值高、易管理、超好用
数字孪生园区场景中的坐标知识
私域流量时代来临,电商企业如何布局?
【Harmony OS】【ARK UI】轻量级数据存储
Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
接口测试框架实战(四)| 搞定 Schema 断言
Kotlin-Flow常用封装类:StateFlow的使用
随机推荐
MCM箱模型建模方法及大气O3来源解析
Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
BIOTIN ALKYNE CAS:773888-45-2价格,供应商
Detailed explanation of MOSN reverse channel
Build your own web page on raspberry pie (1)
【Harmony OS】【ArkUI】ets开发 图形与动画绘制
Tag stack - stack monotonically preparatory knowledge - lt. 739. The daily temperature
JS bottom handwriting
rosbag工具plotjuggler无法打开rosbag的问题
Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
CAD有生僻字如何打出来、如何提交软件相关问题或建议?
IO process thread -> thread -> day5
[Fine talk] Using native js to implement todolist
Get the Ip tool class
业务表解析-余额系统
BIOTIN ALKYNE CAS: 773888-45-2 Price, Supplier
MCM box model modeling method and source analysis of atmospheric O3
【Harmony OS】【ARK UI】Date 基本操作
GIS数据漫谈(五)— 地理坐标系统
用户密码验证