当前位置:网站首页>刷题-洛谷-P1200 你的飞碟在这儿Your Ride Is Here
刷题-洛谷-P1200 你的飞碟在这儿Your Ride Is Here
2022-08-04 19:44:00 【宋向上_UP】
P1200 你的飞碟在这儿Your Ride Is Here-C语言
1、题目
2、求解过程
(1)第一次 没有考虑到字符个数不到六个的情况
结果:
代码:
//洛谷 P1200 你的飞碟在这儿Your Ride Is Here
#include <stdio.h>
#define NUM 7 //一定要注意字符串结束符'\0'
int main() {
char temp;
int star=1;//彗星
int ranks=1;//队伍
int i;
for (i = 0; i < NUM; i++) {
scanf("%c", &temp);
if (temp >= 'A' && temp <= 'Z') {
star = star * (temp - 64);
}
}
star = star % 47;
//printf("%d", star);
for (i = 0; i < NUM; i++) {
scanf("%c", &temp);
if (temp >= 'A' && temp <= 'Z') {
ranks = ranks * (temp - 64);
}
}
ranks = ranks % 47;
//printf("%d %d", star,ranks);
if (star == ranks) {
printf("GO");
}
else {
printf("STAY");
}
return 0;
}
(2)第二次
结果:
代码:
//洛谷 P1200 你的飞碟在这儿Your Ride Is Here
#include <stdio.h>
#define NUM 7 //一定要注意字符串结束符'\0'
int main() {
char temp;
int star=1;//彗星
int ranks=1;//队伍
int i;
for (i = 0; i < NUM; i++) {
scanf("%c", &temp);
if(temp=='\n'){
break;
}
if (temp >= 'A' && temp <= 'Z') {
star = star * (temp - 64);
}
}
star = star % 47;
//printf("%d", star);
for (i = 0; i < NUM; i++) {
scanf("%c", &temp);
if(temp=='\n'){
break;
}
if (temp >= 'A' && temp <= 'Z') {
ranks = ranks * (temp - 64);
}
}
ranks = ranks % 47;
//printf("%d %d", star,ranks);
if (star == ranks) {
printf("GO");
}
else {
printf("STAY");
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
SAP 电商云 Accelerator 和 Spartacus UI 的工作机制差异
"WAIC 2022 · hackers marathon" two ants wealth competition invited you to fight!
awk 统计平均 最大 最小值
目标检测的发展与现状
visual studio 与 visual studio code
六月 致 -.-- -..- -
Pedestrian fall detection experiment based on YOLOV5
使用 Chrome 开发者工具的 lighthouse 功能分析 web 应用的性能问题
If it is test axi dma catch a few words here
MySQL远程备份策略举例
Differences in the working mechanism between SAP E-commerce Cloud Accelerator and Spartacus UI
简易数据缓存层的建立
如何给MySQL添加自定义语法 ?
正畸MIA微种植体支抗技术中国10周年交流会在沈举办
Aura clock chip generation configuration file script
七夕福利!中奖名单:书籍免费送!
June To -.-- -..- -
The Development and Current Situation of Object Detection
TritonVM——基于Recursive STARK的虚拟机
JS new一个构造器发生了什么?从零手写一个new方法