PAT甲1031 Hello World for U【字符串】】的更多相关文章

1031 Hello World for U (20 分) Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowo That is, the characters must be printed in the original order,…
#include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; ; char s1[maxn],s2[maxn],s3[maxn],s4[maxn]; int a,b,c; ][]={"MON","TUE","WED","THU","F…
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line…
题目链接 https://pintia.cn/problem-sets/994805260223102976/problems/994805290334011392 题解 emmm.对于每个身份证号,判断前17位是否合法,并计算其与对应权重积之和,最后判断校验位是否合法. // PAT BasicLevel 1031 // https://pintia.cn/problem-sets/994805260223102976/problems/994805290334011392 #include…
#include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> using namespace std; int n; int n1,n2,n3; ]; int main() { scanf("%s",str); n=strlen(str); n1=n3=(n+)/; n2=n+-n1-n3; //p…
计算A+B的和,并且按标准格式处理,每3个就要有个逗号 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int main() { int a,b; scanf("%d %d",&a,&b); int sum=a+b; ]; sprintf(str,"%d"…
又是一道字符串处理的题目... 题意:给出两个浮点数,询问它们保留n位小数的科学计数法(0.xxx*10^x)是否相等.根据是和否输出相应答案. 思路:先分别将两个浮点数转换成相应的科学计数法的格式1.point为小数点的索引,初始化为字符串的长度len2.not0位第一个非0的数字的索引,初始化为len如果not0为len,表明该浮点数为0,特殊处理,形式为0.0..0*10^0否则根据point和not0的大小,计算相应的指数.接着便是从str的not0开始,给ans赋值,共n位不包括小数点…
题意:给出科学计数法的格式的数字A,要求输出普通数字表示法,所有有效位都被保留,包括末尾的0. 分两种情况,一种E+,一种E-.具体情况具体分析╮(╯_╰)╭ #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cmath> #define POSITIVE 1 #define NEGATIVE 2 using names…
求给出数的平均数,当然有些是不符合格式的,要输出该数不是合法的. 这里我写了函数来判断是否符合题目要求的数字,有点麻烦. #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; ; bool islegal(char*str){ int len=strlen(str); ,; ;i<len;i++){ //if…
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is ofte…