当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
猜你喜欢
getBoundingClientRect
JS new一个构造器发生了什么?从零手写一个new方法
Use "green computing" technology to promote sustainable development of computing power
Defaced Fingerprint Recovery and Identification
ERC20转账压缩
正则表达式未完
The book "The Essence of Alipay Experience Design", a record of knowledge related to testing
IIC驱动OLED
笔记本WIFI无法上网(无Internet访问权限)
图片延迟加载、预加载
随机推荐
「 WAIC 2022 · 黑客马拉松」蚂蚁财富两大赛题邀你来战!
2022年国内手机满意度榜单:华为稳坐国产品牌第一
带你了解数据分布式存储原理
Go study notes (Part 1) Configuring the Go development environment
T+Cloud:构建新型生意社交网络和营销关系的“智公司”
元国度链游系统开发
哈佛架构 VS 冯·诺依曼架构
Go学习笔记(篇一)配置Go开发环境
Finger Vein Recognition-matlab
Switch node version and switch npm source tool
用“绿色计算“技术推动算力可持续发展
zynq 记录
How to manually download and install SAP Fiori tools - Extension Pack for Visual Studio Code
Embrace the Cmake child is simple and practical, but inflexible
红外图像滤波
Exploration and Practice of Database Governance
指静脉识别-matlab
一些性能测试的要点
编译optimize源码实现过程
二叉树的遍历