1100. Mars Numbers (20)

news/2025/11/23 17:27:44/文章来源:https://www.cnblogs.com/WJQ2017/p/19261065

1100. Mars Numbers (20)

#include <iostream>
#include <string.h>using namespace std;char ch[2][13][5] = 
{"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec","", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"
};int getindex(int index, char s[])
{int i;for(i = 0; i < 13; i++){if(strcmp(ch[index][i], s) == 0){return i;}}return -1;
}int main()
{int n;scanf("%d", &n);getchar();int i, len, num, j, k, low, high, index;char s[20], curs[5];for(i = 1; i <= n; i++){gets(s);len = strlen(s);if(s[0] >= '0' && s[0] <= '9'){num = 0;for(j = 0; j < len; j++){num = num * 10 + s[j] - '0';}if(num < 13){printf("%s\n", ch[0][num]);}else{low = num % 13;high = num / 13;printf("%s", ch[1][high]);if(low > 0){printf(" %s\n", ch[0][low]);}else{printf("\n");}}}else{if(len <= 4){for(j = 0; j <= 1; j++){index = getindex(j, s);if(index != -1){break;}}if(j == 0){num = index;}else {num = 13 * index;}}else{for(j = 0; s[j] != ' '; j++){curs[j] = s[j];}curs[j] = '\0';num = getindex(1, curs) * 13;for(k = j + 1, j = 0; k < len; k++, j++){curs[j] = s[k];}curs[j] = '\0';num += getindex(0, curs);}printf("%d\n", num);}}system("pause");return 0;
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/974067.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

解码网络编程基础

进程间通信方式 基础概念 程序是数据和指令的集合,运行时成为进程,操作系统会为其分配资源并记录参数。同一主机内进程通信可通过管道、信号、消息队列、信号量集、共享内存实现,这些方式依赖主机本地系统资源,无法…

C++的3种继承方式

C++的3种继承方式 在 C++ 中,继承方式(public、protected、private)决定了基类成员在派生类中的访问权限,以及派生类对象对基类成员的访问权限。正确选择继承方式是实现封装、复用和多态的关键。以下是三种继承方式…

1082. Read Number in Chinese (25)

1082. Read Number in Chinese (25)#include <iostream> #include <string.h>using namespace std;int first = 1;void setfirst() {if(first == 1){first = 0;}else{printf(" ");} }int main()…

1081. Rational Sum (20)

1081. Rational Sum (20)#include <iostream>using namespace std;long long getsame(long long a, long long b) {if(b != 0){return getsame(b, a % b);}else{return a;} }void simplify(long long &a, lo…

1067. Sort with Swap(0) (25)

1067. Sort with Swap(0) (25)#include <iostream>using namespace std;int index[100010], num[100010];int main() {int n;scanf("%d", &n);int i, count = 0;for(i = 0; i < n; i++){scanf(…

1066. Root of AVL Tree (25)

1066. Root of AVL Tree (25)#include <iostream> #include <stdlib.h>using namespace std;typedef struct node {int key, bf;struct node *lchild, *rchild; }*bnode;void rrotate(bnode *root) {bnode…

1070. Mooncake (25)

1070. Mooncake (25)#include <iostream> #include <algorithm>using namespace std;struct node {double amounts, prices, perprice; }mooncakes[1010];int cmp(node n1, node n2) {return n1.perprice …

1069. The Black Hole of Numbers (20)

1069. The Black Hole of Numbers (20)#include <iostream> #include <string.h> #include <algorithm>using namespace std;int cmp(char a, char b) {return a > b; }int main() {int num[2];s…

1050. String Subtraction (20)

1050. String Subtraction (20)#include <iostream> #include <string.h>using namespace std;int flag[130]; char s[2][10010];int main() {int i, len[2];for(i = 0; i <= 1; i++){gets(s[i]);len[i…

1049. Counting Ones (30)

1049. Counting Ones (30)#include <iostream>using namespace std;int main() {int n;scanf("%d", &n);int low, mid, high, d = 1, res = 0;while(n >= d){high = n / (d * 10);mid = (n - h…

1045. Favorite Color Stripe (30)

1045. Favorite Color Stripe (30)#include <iostream>using namespace std;int fav[210], ori[10010], res[210][10010];int getmax(int a, int b) {if(a > b){return a;}else{return b;} }int main() {int …

1048. Find Coins (25)

1048. Find Coins (25)#include <iostream> #include <algorithm>using namespace std;int c[510], num[100010];int main() {int n, m;scanf("%d%d", &n, &m);int i;for(i = 1; i <…

1052. Linked List Sorting (25)

1052. Linked List Sorting (25)#include <iostream> #include <algorithm> #include <vector>using namespace std;struct node {int address, key, next; }nod[100000];int cmp(node n1, node n2)…

1051. Pop Sequence (25)

1051. Pop Sequence (25)#include <iostream> #include <stack>using namespace std;int main() {int m, n, k;scanf("%d%d%d", &m, &n, &k);int i, num[1010], j, index, flag, be…

卡塔兰long long

1.mod 我们用递推式用加法避免除和mod include <bits/stdc++.h> using namespace std; long long dp[105]; long long f(int x) { if(dp[x]!=-1) return dp[x]; dp[x]=0;//归0 for(int i=0;i<x;i++) { dp[x]=…

1038. Recover the Smallest Number (30)

1038. Recover the Smallest Number (30)#include <iostream> #include <string.h> #include <string> #include <algorithm> #include <vector>using namespace std;int cmp(string a,…

1037. Magic Coupon (25)

1037. Magic Coupon (25)#include <iostream> #include <vector> #include <algorithm>using namespace std;int main() {int nc;scanf("%d", &nc);int i;vector<long long> v[…

1040. Longest Symmetric String (25)

1040. Longest Symmetric String (25)#include <iostream> #include <string.h>using namespace std;int main() {char s[1010];gets(s);int len = strlen(s), i, count, res = 0, j, k;for(i = 0; i <…

1029. Median (25)

1029. Median (25)#include <iostream> #include <vector> #include <algorithm>using namespace std;int main() {int n;scanf("%d", &n);int i;long int num;vector<long int>…

1039. Course List for Student (25)

1039. Course List for Student (25)#include <iostream> #include <vector> #include <algorithm>using namespace std;vector<int> v[270000];int getbigindex(char s[]) {return (s[0] - A…