当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
猜你喜欢
随机推荐
The list of Kubernetes - watch mechanism
C#弹出询问对话框
运维就业现状怎么样?技能要求高吗?
JS new一个构造器发生了什么?从零手写一个new方法
Regular expression is incomplete
Ant Group's time series database CeresDB is officially open source
量化交易机器人系统开发
[Latest Information] 2 new regions will announce the registration time for the soft exam in the second half of 2022
"WAIC 2022 · hackers marathon" two ants wealth competition invited you to fight!
小软件大作用 | 如何省时省力进行Gerber图层快速对比?
Zip4j使用
nr部分计算
Kubernetes之list-watch机制
c sqlite...
SIGIR 2022 | 邻域建模Graph-Masked Transformer,显著提高CTR预测性能
Use "green computing" technology to promote sustainable development of computing power
SAP 电商云 Accelerator 和 Spartacus UI 的工作机制差异
VQ Realization of Wavelet Extraction Features
基于HDF的LED驱动程序开发(2)
高效目标检测:动态候选较大程度提升检测精度(附论文下载)