C语言程序设计
J_北冥有鱼
这个作者很懒,什么都没留下…
展开
-
1045 快速排序
#include <iostream>#include <algorithm>using namespace std;int main(){ int N, max = 0, cnt = 0; cin >> N; int a[N], b[N], c[N]; for(int i = 0; i < N; i++){ cin >> ...原创 2020-01-01 21:29:24 · 65 阅读 · 0 评论 -
C语言程序设计-1044 火星数字
#include <iostream>#include <algorithm>#include <string>#include <sstream>using namespace std;int main(){ string s; char gewei[][13] = {"tret", "jan", "feb", "mar", "ap...原创 2020-01-01 20:47:44 · 253 阅读 · 0 评论 -
C语言程序式设计-1072 开学寄语
测试点1、3错误#include <iostream>using namespace std;#include <string>int main(){ int N, M, n, a[10000] = {0}, k, xuhao, flag, renshu=0, wuping=0; char name[5]; cin >> N >>...原创 2020-01-01 14:21:37 · 169 阅读 · 0 评论 -
C语言程序设计-1048 数字加密
#include <iostream>#include <string>using namespace std;int main(){ string a, b; cin >> a >> b; int lena, len, lenc, c[100]={0}; lena = a.length(); len = b.length(); len...原创 2020-01-01 13:38:27 · 1135 阅读 · 0 评论 -
1059 C语言竞赛
!!!判断素数,i <= sqrt(n); 是小于等于,如果只是小于是错的!这是map 方法。#include <iostream>#include <cmath>#include <string>#include <map>using namespace std;bool isprime(int n){ int flag = ...原创 2020-01-01 13:22:22 · 108 阅读 · 0 评论 -
1055 集体照
#include <iostream>#include <algorithm>#include <string>#include <vector>using namespace std;struct node{ string name; int height;};bool cmp(const node &a, const no...原创 2020-01-01 12:39:02 · 102 阅读 · 0 评论 -
1034 有理数四则运算
日了狗,这么流畅的代码以及思路,过不了最后两个测试点。#include <iostream>using namespace std;int gcd(int a, int b){ return b==0?a:gcd(b, a%b);}void print(int a, int b){ int yue, shang, yu, flag = 0; if(b == 0) pri...原创 2019-12-31 18:55:41 · 335 阅读 · 0 评论 -
C语言程序设计-1031 查验身份证
#include <stdio.h>int main(){ int n, z, quan[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}, cnt=0; char ch, m, yanzheng[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', ...原创 2019-12-31 16:55:38 · 648 阅读 · 0 评论 -
C语言程序设计-1028 人口普查
妈个鸡,输出为0 的时候不能带空格!但使用scanf("%s %d/%d/%d"…)读不到数,scanf("%s", &name)也读不到数,why?#include <iostream>#include <string>using namespace std;int main(){ int N, year, month, day, young = 0,...原创 2019-12-31 16:25:32 · 644 阅读 · 0 评论 -
C语言程序设计-1014 福尔摩斯的约会
妈了个鸡,老子这么优秀的代码第二个测试点死活过不去#include <iostream>#include <string>using namespace std;int main(){ string s1, s2, s3, s4, week[7] = {"Mon", "TUE", "WED", "THU", "FRI", "SAT", "SUN"}; int n...原创 2019-12-31 15:25:59 · 205 阅读 · 0 评论 -
1009 Product of Polynomials
#include <iostream>#include <algorithm>#include <map>#include <vector>using namespace std;int main(){ int na, nb, exp, cnt = 0; double coe; cin >> na; map<int...原创 2019-12-31 11:50:45 · 88 阅读 · 0 评论 -
PAT甲级-1006 Sign In and Sign Out
很奇怪为什么scanf取不到数据。#include <iostream>#include <map>using namespace std;int main(){ int N, open, leave, min = 235959, max=0; string id, t1, t2, zao, wan; map<int, string> ma; c...原创 2019-12-30 22:30:02 · 56 阅读 · 0 评论 -
C语言程序设计-1060 爱丁顿数
说实话没读懂这个题目。https://blog.csdn.net/weixin_42582136/article/details/89353469#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){ int n; cin &g...原创 2019-12-30 18:45:11 · 176 阅读 · 0 评论 -
C语言程序设计-1024 科学计数法
#include <iostream>using namespace std;int main(){ string s, s1, s2, s3, ans; cin >> s; s1 = s.substr(0, 2); s2 = s.substr(3, s.find('E')-3); s3 = s.substr(s.find('E')+1); if(s...原创 2019-12-30 16:58:28 · 698 阅读 · 0 评论 -
C语言程序设计-1065 单身狗
#include <iostream>#include <algorithm>#include <map>#include <vector>using namespace std;int main(){ int N, n1, n2, M, m, a[100000]={0}, cnt = 0, flag = 0; cin >>...原创 2019-12-30 13:32:22 · 214 阅读 · 0 评论 -
C语言程序设计-1069 微博转发抽奖
普通方法,34测试点过不了——因为keep 的K没有大写。。。。。#include <iostream>#include <string>using namespace std;int main(){ int m, n, s, j = 0; cin >> m >> n >> s; getchar(); string ans...原创 2019-12-30 12:15:23 · 209 阅读 · 0 评论 -
C语言程序设计-1075 链表元素分类
第四个测试点错误,第五个运行超时,代码应该没有错啊,难道是空间使用太多了?#include <iostream>using namespace std;int main(){ int first, n, k, head, num, next; cin >> first >> n >> k; int a1[100000]={0}, a2[1...原创 2019-12-30 09:49:42 · 161 阅读 · 0 评论 -
C语言程序设计-1080 MOOC期终成绩
最后一个测试点没过。#include <iostream>#include <algorithm>#include <string>#include <vector>#include <cmath>#include <unordered_map>using namespace std;struct node{...原创 2019-12-29 22:33:35 · 443 阅读 · 0 评论 -
C语言程序设计-1084 外观数列
#include <iostream>#include <algorithm>#include <string>using namespace std;int main(){ int N; string d; cin >> d >> N; while(--N){ char first = d[0]; int cnt...原创 2019-12-29 21:37:24 · 219 阅读 · 0 评论 -
C语言程序设计-1085 PAT单位排行
https://blog.csdn.net/liuchuo/article/details/79682176#include <iostream>#include <algorithm>#include <vector> #include <unordered_map>using namespace std;struct node{...原创 2019-12-29 15:40:47 · 115 阅读 · 0 评论 -
C语言程序设计-1088 三人行
自己的垃圾代码,思路错误了,将甲的十位和各位拆开进行遍历,造成双重循环,而且容易出bug。对于两种方式计算丙值的比较也错误了,int == int 是明显错误的,double == double也是不对的,因为double也有一定的精度问题,只有判断int == double 才能得到正确的结果。#include <iostream>#include <string>...原创 2019-12-29 10:36:37 · 176 阅读 · 0 评论 -
C语言程序设计-1094 谷歌的招聘
输出结果必须是字符串型,题目中其实有提示0023#include <iostream>#include <string>#include <cmath>using namespace std;int isprime(int n);int main() { int n, k, num, flag = 0; string s, cs; cin &...原创 2019-12-28 22:26:29 · 302 阅读 · 0 评论 -
C语言程序设计-1081 检查密码
有个测试点是关于字符中有空格的,所以只能使用getline,用scanf 或者 cin 都会失分。#include <iostream>#include <string>using namespace std;int main() { int n, flag1, flag2, flag3; string s; cin >> n; getchar()...原创 2019-12-28 21:41:28 · 759 阅读 · 0 评论 -
C语言程序设计-1079 延迟的回文数
#include <iostream>#include <algorithm>using namespace std;int main() { string s, rs, sum; int cnt = 0, flag = 1, yu=0, jin=0; cin >> s; while(flag){ rs = s; sum = ""; yu = ...原创 2019-12-28 19:35:28 · 135 阅读 · 0 评论 -
C语言程序设计-1074 宇宙无敌加法器
#include <iostream>#include <cmath>using namespace std;int main() { //string s, ans=""; int N, n1, n2, flag = 1, jinzhi, a, b, yushu, jinwei=0, ans=0, cnt=0; cin >> N >> ...原创 2019-12-28 18:41:52 · 309 阅读 · 0 评论 -
C语言程序设计-1067 试密码
#include <iostream>#include <cstring>using namespace std;int main() { string str, s; int n, i; cin >> str >> n; getchar(); for(i = 0; i < n; i++){ getline(cin, s);...原创 2019-12-28 15:16:56 · 254 阅读 · 0 评论 -
C语言程序设计-1062 最简分数
#include <iostream>using namespace std;int gcd(int a,int b);int main() { long int n1, m1, n2, m2, k, mi, ma, i, flag=0; scanf("%ld/%ld %ld/%ld %ld",&n1,&m1,&n2,&m2,&k...原创 2019-12-28 14:58:20 · 470 阅读 · 0 评论 -
C语言程序设计-1051 复数乘法
#include <iostream>#include <algorithm>#include <cmath>using namespace std;int main() { double r1, p1, r2, p2, a, b, accuracy = 0.01; cin >> r1 >> p1 >> r2 &g...原创 2019-12-28 11:21:00 · 270 阅读 · 0 评论 -
C语言程序设计-1033 旧键盘打字
#include <iostream>#include <string>using namespace std;int main(){ string s; int cnt = 0; char ch; getline(cin, s); while(ch != '\n'){ ch = getchar(); if( s.find(toupper(ch)) ...原创 2019-12-27 13:21:34 · 124 阅读 · 0 评论 -
C语言程序设计-1030 完美数列
#include <iostream>#include <algorithm>#include <vector>using namespace std;int main(){ long int N, p, cnt=0, maxcnt=0, i, j; cin >> N >> p; vector<long> v(...原创 2019-12-27 09:56:44 · 207 阅读 · 0 评论 -
C语言程序时设计-1020 月饼
#include <iostream>#include <algorithm>using namespace std;struct node{ double cunliang, shoujia, danjia;};int cmp(struct node a, struct node b){ return a.danjia > b.danjia;}...原创 2019-12-26 17:08:11 · 380 阅读 · 0 评论 -
C语言程序设计-1019 数字黑洞
四个测试点错误,找不出。第二个测试点,关于输入为6174,需要执行一遍再结束。第三四个测试点,如果输入的为1000, 第一次相减得1,需要补全四位才行,所以大部分网友用字符串和数值相互转化的思路在做。#include <iostream>#include <math.h>using namespace std;int main(){ int N, sheng...原创 2019-12-26 15:14:52 · 239 阅读 · 0 评论 -
C语言程序设计-1018 锤子剪刀布
// 采用相减将结果存入数组的方法进行统,甲用绝对值记录,乙用绝对值加10记录好了// 甲胜情况,C - J = -7; J - B = 8; B - C = -1;// 不能使用map,因为可能出现多次完全一样的情况。// 获胜的手势 BCJ升序 刚好对应序号1、7、8升序,所以倒着遍历,正好输出字母排序最小的结果#include <iostream>#include &l...原创 2019-12-26 12:47:28 · 185 阅读 · 0 评论 -
C语言程序设计-1017 A除以B
#include <iostream>using namespace std;#include <string>int main(){ string A; int B, a = 0, Q[1001] = {0}, R, j=0; //scanf("%s %d", &A, &B); //为什么scanf读不到数 cin &...原创 2019-12-26 10:01:54 · 506 阅读 · 0 评论 -
C语言程序设计-1066 图像过滤
#include <iostream>using namespace std;int main(){ int M, N, A, B, tihuan, i, j, n; cin >> M >> N >> A >> B >> tihuan; for(i = 0; i < M; i++){ for(j = ...原创 2019-12-25 16:22:41 · 134 阅读 · 0 评论 -
C语言程序设计-1058 选择题
部分错误,有两分没有得到#include <iostream>#include <string>#include <cctype>using namespace std;int main(){ int N, M, cnt, xuanze, score, flag, max=0; cin >> N >> M; strin...原创 2019-12-25 14:42:58 · 332 阅读 · 0 评论 -
C语言程序设计-1057 数零壹
#include <iostream>#include <string>#include <cctype>using namespace std;int main(){ string str; int sum, a[2] = {0}; getline(cin, str); for(int i = 0; i < str.length();...原创 2019-12-25 13:02:21 · 201 阅读 · 0 评论 -
C语言程序设计-1053 住房空置率
#include <iostream>#include <string>using namespace std;int main(){ double N, e, D, K, dian, cnt, flag1=0, flag2=0; cin >> N >> e >> D; for(int i = 0; i < N; i...原创 2019-12-25 12:21:42 · 105 阅读 · 0 评论 -
C语言程序设计-1027 打印沙漏
关键是要把各层的数目以及关系计算出来:n为半边沙漏的层数,总数为N;因此,总层数为2n-1,总数为 N = 2nn - 1, 最上层个数2n-1。根据N求出n,以及可以剩余的个数。再然后,计算每一层层号和空格与字符之间的关系。设最上层为第n层,则各层中间符号数为center = 2i -1,左边空格数为 left = ((2n-1) - center) / 2, 使用一个while循环就可以...原创 2019-12-25 10:18:37 · 802 阅读 · 0 评论 -
C语言程序设计-1026 程序运行时间
#include<iostream>#include<math.h>using namespace std;//#define CLK_TCK = 100;int main(){ int sum, sec, min, hour; double A, B; cin >> A >> B; sum = round( (B - A) ...原创 2019-12-25 09:09:56 · 140 阅读 · 0 评论