PAT(B)
_binary
这个作者很懒,什么都没留下…
展开
-
PAT(B)1002. 写出这个数 (20)
#include #include int main(){ char pinyin[][5] = { "ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu" }; char a[100]; int sum = 0; scanf("%s", &a); for (size_t i = 0; i <原创 2015-02-09 19:37:16 · 960 阅读 · 0 评论 -
PAT(B)1022. D进制的A+B (20)
#include using namespace std;int main(){ int a, b, d; cin >> a >> b >> d; int s = a + b; int t[32] = { 0 }; int k = 0, n = 0; while (s >= d){ t[k++] = s%d; s /= d; } t[k]原创 2015-03-24 08:06:57 · 489 阅读 · 0 评论 -
PAT(B)1023. 组个最小数 (20)
#include using namespace std;int main(){ int a[10] = { 0 }; for (int i = 0; i 10; ++i){ cin >> a[i]; } int min = 0; for (int i = 1; i 10; ++i){ if (a[i] != 0){ cout break原创 2015-03-24 08:16:09 · 344 阅读 · 0 评论 -
PAT(B)1016. 部分A+B (15)
#include using namespace std;int main(){ int a, da, b, db; int pa = 0, pb = 0; cin >> a >> da >> b >> db; while (a > 0){ if (a % 10 == da) pa = pa*10+ da; a /= 10; } while (b原创 2015-03-09 22:38:47 · 345 阅读 · 0 评论 -
PAT(B)1014. 福尔摩斯的约会 (20)
#include #include using namespace std;int main(){ string s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; int ct = 0; for (auto i = s1.begin(), j = s2.begin(); i != s1.end() && j != s2.end(原创 2015-03-08 00:48:07 · 568 阅读 · 0 评论 -
PAT(B)1013. 数素数 (20)
#include using namespace std;int isPrime(int n){ for (int i = 2; i*i <= n; ++i) if (n%i == 0) return 0; return 1;}int main(){ int m, n; cin >> m >> n; int ct = 0; int原创 2015-03-07 19:22:59 · 549 阅读 · 0 评论 -
PAT(B)1015. 德才论 (25)
#include #include #include #include using namespace std;struct stu{ int num; int scored; int scorec; bool operatorconst stu &tmp) const{ //重载运算符 if (scorec+scored != tmp.原创 2015-03-08 23:38:16 · 470 阅读 · 0 评论 -
PAT(B)1012. 数字分类 (20)
#include #include using namespace std;int main(){ int n, num; int a[6] = { 0 }; int b = 1; int ct1 = 0, ct2 = 0; cin >> n; while (n--){ cin >> num; if (num % 10 == 0) a[1]原创 2015-03-05 21:58:36 · 353 阅读 · 0 评论 -
PAT(B)1010. 一元多项式求导 (25)
#include using namespace std;int main(){ int a, b; bool first = false; while (cin >> a >> b){ if (b > 0){ if (first) cout " "; else first = true; cout " " 1; }原创 2015-03-05 20:43:45 · 503 阅读 · 0 评论 -
PAT(B)1009. 说反话 (20)
#include #include #include using namespace std;int main(){ vectorstring> svec; string s; bool first = false; while (cin >> s){ svec.push_back(s); } for (auto c = svec.rbegin();原创 2015-03-02 19:15:20 · 306 阅读 · 0 评论 -
PAT(B)1008. 数组元素循环右移问题 (20)
思路:参考原文数组循环移位#include using namespace std;//对数组a,逆序排列a[i]到a[j]的值void Reverse(int a[], int i, int j){ for (; i < j; ++i, --j){ int temp = a[i]; a[i] = a[j]; a[j] = temp;转载 2015-03-02 18:44:22 · 403 阅读 · 0 评论 -
PAT(B)1007. 素数对猜想 (20)
思路:用筛选法求出n内所有素数#include #include using namespace std;const int range = 100000;bool IsPrime[range + 1];void set(bool IsPrime[],int range){ int i, j; for (i = 0; i <= range; ++i)原创 2015-03-02 22:17:43 · 375 阅读 · 0 评论 -
PAT(B)1005. 继续(3n+1)猜想 (25)
思路:用一个数组记录下验证每个数字时产生的过程值 最后输出时与这个数组进行比较#include #include using namespace std;int Compare(int a, int b){ return a > b;}int main(){ int k; int a[100]; //保存待验证的正整数 int b[100] = { 0原创 2015-03-02 20:56:39 · 375 阅读 · 0 评论 -
pat(B)1011. A+B和C (15)
#include #include using namespace std;int main(){ int t; long a, b, c; int ct = 0; cin >> t; while (t--){ cin >> a >> b >> c; if (a + b > c) printf("Case #%d: true\n", ++ct);原创 2015-03-02 22:52:44 · 398 阅读 · 0 评论 -
PAT(B)1006. 换个格式输出整数 (15)
#include using namespace std;int main(){ int n; cin >> n; if (n >= 100){ for (int i = 0; i 100; ++i) cout "B"; n %= 100; } if (n >= 10){ for (int i = 0; i 10; ++i)原创 2015-03-02 19:01:10 · 350 阅读 · 0 评论 -
PAT(B)1004. 成绩排名 (20)
#include int main(){ struct{ char name[11]; char id[11]; int score; } a[100]; int n, p, q; int max = 0,min = 100; scanf("%d", &n); for (int i = 0; i < n; ++i){ scan原创 2015-02-10 22:40:51 · 533 阅读 · 0 评论 -
PAT(B)1021. 个位数统计 (15)
#include #include using namespace std;int main(){ string s; cin >> s; int a[10] = { 0 }; for (int i = 0; i < s.length(); ++i){ ++a[s[i] - '0']; } for (int i = 0; i 10; ++i){原创 2015-03-24 07:53:13 · 350 阅读 · 0 评论