自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 资源 (5)
  • 收藏
  • 关注

原创 scanf()函数如何输入带有空格的字符串

scanf函数遇到 tab 或者 空格或者 \n 的时候视为输入结束scanf如何输入带有空格的字符串呢?scanf("%[^\n]", str);为什么我要纠结这个问题呢?在做PAT时发现,get()函数无法提交,而 char 类型的数据我只会用 get()输入,所以就想用别的方法替代。...

2021-02-23 15:56:14 2154

原创 A1058 A+B in Hogwarts (20 分)

18分代码,不知道哪里扣了2分#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int a, b, c; int x, y, z; scanf("%d.%d.%d %d.%d.%d", &

2021-02-23 09:35:12 49

原创 A1027 Colors in Mars (20 分)

#include <iostream>using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */char redix[13] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'};int main(int arg

2021-02-23 09:34:36 100

原创 B1037 在霍格沃茨找零钱 (20 分)

#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int a, b, c; int x, y, z; int z1, z2, z3; scanf("%d.%d.%d %d.%d.%

2021-02-23 09:34:06 136

原创 B1022 D进制的A+B (20 分)

进制转换通式a是待转换的数字,d是需要转换的进制,z[num]是转换后存放的地方。do{ z[num++] = a % d; a = a / d;}while(a != 0);for(int i = num-1; i >= 0; i--){ cout << z[i];}#include <iostream>using namespace std;/* run this program using the console p

2021-02-23 09:32:10 74

原创 B1027 打印沙漏 (20 分)

最重要的公式推导,等差数列,求和公式。#include <iostream>#include <math.h>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int n; char c; cin >&gt

2021-02-23 09:25:04 107

原创 B1036 跟奥巴马一起编程 (15 分)

#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int num; char c; cin >> num >> c; int row = (double)n

2021-02-23 09:23:53 52

原创 getline和cin区别;getline和cin.getline的区别【简单易懂】

getline: 按行读取, 一次读取多个字符,直到读满N个,或者遇到指定的结束符(自定义的或者EOF或者换行符,不包括空白符)为止。形式:getline(字符指针,字符个数N,结束符);cin读取的话,遇到结束符(包括空白符)会终止,只读取空白符之前的部分。例如:int main(){ string line; getline(cin,line);//输入:12 34 cout<<line<<endl;//输出:12 34 cin>>l..

2021-02-22 22:44:24 5870 1

原创 A1036 Boys vs Girls (25 分)

#include <iostream>using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */struct student{ char name[15]; char id[15]; int score;}m, f, temp;void init(){ m.score = 101; f.sc

2021-02-16 21:30:25 163

原创 A1011 World Cup Betting (20 分)

#include <iostream>#include <algorithm>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */char S[3]={'W', 'T', 'L'};int main(int argc, char** argv) { double a, ans =

2021-02-16 21:29:50 154

原创 B1032 挖掘机技术哪家强 (20 分)

#include <iostream>using namespace std;const int maxn = 100001;struct info{ int score = 0;}school[maxn];int main(int argc, char** argv) { int n; cin >> n; int id, score; int max_id, max_score = 0; while(n--){ cin >&gt

2021-02-16 21:29:17 49

原创 B1028 人口普查 (20 分)

写的太乱了#include <iostream>#include <string.h>using namespace std;struct person{ char name[10]; int yy, mm, dd;}youngest, oldest, left2, right2, temp;bool lessEqu(person a, person b){ if(a.yy != b.yy){ return a.yy <= b.yy; } else

2021-02-16 21:28:45 62

原创 B1004 成绩排名 (20 分)

#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int maxn = 101;struct Student{ string name; string id;}score[maxn];int main(int argc, char**

2021-02-16 21:28:15 96

原创 B1041 考试座位号 (15 分) 【结构体】

第一次用结构体~~#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int MAXN = 1001;struct Student{ long long id; int examSeat;}testSeat[MAXN];int main(

2021-02-16 21:27:43 145

原创 A1009 Product of Polynomials (25 分)

易错点: 答案的系数至少要2001,因为两个最高幂次为1000的多项式相乘,最高次幂可以达到2000.#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int n, m, count = 0;

2021-02-16 21:27:02 84 2

原创 A1002 A+B for Polynomials (25 分)

易错点:会使用count计数,这里要注意正负抵消的问题,两个多项式的某一个相同幂次得到项可能刚好为相反数,这样就会导致相加后为0了。因此要注count必须在两项相加后再判断是否自减。输出时格式上要注意,需要保留一位小数。printf("%.1f", i);代码:#include <iostream>using namespace std;int main(int argc, char** argv) { int n, m, count = 0; cin

2021-02-16 21:26:32 115

原创 B1026 程序运行时间

新知识:C++四舍五入click = (c2 - c1 + 50) / 100;浮点数的话加0.5输出固定位数,并且不够补0printf("%02d", a);代码#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(in

2021-02-16 21:26:00 60

原创 B1010 一元多项式求导(25分)

#include <iostream>using namespace std;int main(int argc, char** argv) { int k, e; cin >> k >> e; if(e == 0){ cout << "0 0"; } else cout << k * e << " " << e-1; while(cin >> k >> e){ if(e

2021-02-10 20:31:03 54

原创 A1046 Shortest Distance (20 分)

部分超时#include <iostream>#include <algorithm>using namespace std;/*5 1 2 4 14 911 3*/int main(int argc, char** argv) { int n, a[100001]; int m; int sum = 0, max = 0; cin >> n; for(int i = 0; i < n; i++){ sum += a[i];..

2021-02-10 20:30:34 132

原创 A1042 Shuffling Machine (20 分)

#include <iostream>using namespace std;int main(int argc, char** argv) { string begin[54] = { "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "S10", "S11", "S12", "S13", "H1", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9", "H10", "H1

2021-02-10 20:29:45 47

原创 B1018 锤子剪刀布 (20 分)

思路:题解一个比较巧妙的地方: 如何判断石头剪刀布的谁胜谁负呢 ?通过下面代码,将所出的转换为数字012,然后通过此处 (k1 + 1) % 3 == k2 可以判断出是谁赢。int change(char c){ if(c == 'B') return 0; else if(c == 'J') return 1; else if(c == 'C') return 2;}代码#include <iostream>using namespace std;/* run th

2021-02-10 20:29:14 52

原创 B1012 数字分类 (20 分)

#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int a[1001]; int count[5] = {0}; int ans[5] = {0}; int flag = 1; in

2021-02-10 20:28:42 158

原创 B1008 数组元素循环右移问题 【思路】

思路:题目中虽然给出了很多限制条件,例如不允许使用另外的数组,又要考虑移动的次数要少,但实际上可以不管过程,直接输出答案即可。首先需要注意题目没给出M最大值,因此不能直接认为M<N,所以需要这步:M=M%N。在得到新的M后直接输出从N-M号元素到N-1元素,再输出0号到N-M-1号元素即可。#include <iostream>using namespace std;int main(int argc, char** argv) { int n, m; i

2021-02-10 20:28:21 141

原创 B1046 划拳

#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int n; cin >> n; int a, a1, b, b1; int fileA = 0, fileB = 0;

2021-02-10 20:27:28 46

原创 B1016 部分A+B 【思路】

思路: 通过对整数每位取余,算出来的。代码:#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int a, da, b, db; int pa = 0, pb = 0; cin

2021-02-10 20:26:55 55

原创 B1011 A+B和C

#include <iostream>using namespace std;int main(int argc, char** argv) { int T, tcase = 1; cin >> T; while(T--){ long long int a, b, c; cin >> a >> b >> c; if(a + b > c){ printf("Case #%d: true\n", tcase++)

2021-02-10 20:26:14 46

原创 B001 害死人不偿命的(3n+1)猜想

#include <iostream>using namespace std;int main(int argc, char** argv) { int n,step = 0; cin >> n; while(n != 1){ if(n %2 == 0) n = n / 2; else n = (3 * n + 1) / 2; step++; } cout << step; return 0;}

2021-02-10 20:25:14 56

原创 1006 Sign In and Sign Out (25 分)

思路时间格式都是定长的,用 string 存,进行比较即可可以不用数组存,每次遍历循环直接比较代码#include <iostream>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char** argv) { int n; strin

2021-02-03 11:14:00 58

原创 1005 Spell It Right (20 分)

新知识string str = "abcde" 获取某个字符可以用 str[i]字符类型变为数字类型则str[i] - '0'将数字转为字符串类型 string str2 = to_string(sum); 引入头文件 #include<string>代码#include <iostream>#include<string>using namespace std;int main(int argc, char** argv) { st

2021-02-02 18:58:29 61

原创 1001 A+B Format (20分)

思路:加法计算为了后续处理方便,把和转为字符串判断和是否为负数若为负数,输出负号,并把字符串去掉负号非负数则不做处理循环遍历,每3位插入一个“,”代码:#include<iostream>#include<string>#include<sstream>using namespace std;int main(){ int a, b, ans; cin >> a >> b; ans = a + b;

2021-02-02 15:36:54 95

原创 C++基础知识 istringstream和ostringstream

1. istringstream和ostringstream标准库中提供了相关的类对字符串和数字进行转换:字符串流类(sstream)用于string的转换。1.1 istringstream:string转数字1.2 ostringstream:数字转string字符串和数字的转换:#include <iostream>#include <sstream>#include <string>using namespace std;#defin

2021-02-02 15:12:04 320

原创 C++基础知识--size和length区别

C++标准库中的string中两者的源代码如下: size_type __CLR_OR_THIS_CALL length() const { // return length of sequence return (_Mysize); } size_type __CLR_OR_THIS_CALL size() const { // return length of sequence

2021-02-02 15:09:08 4250

一些面试题【Java后端】

一些面试题【Java后端】

2022-03-23

【Android】用Fragment、Viewpage实现tab栏切换

【Android】用Fragment、Viewpage实现tab栏切换

2022-03-03

UML试题及答案-(5).doc

UML试题及答案-(5).doc

2021-04-29

全网最全安卓复习资料PPT+复习题

全网最全安卓复习资料,内附PPT和题库,还有某一年的学校真题,安卓四大组件,选择题,填空题,多选题,简答题,编程题。仅供参考!仅供参考!仅供参考!仅供参考!仅供参考!仅供参考!

2020-11-24

中北大学安卓实验2-8

内含两份代码,均可运行,附实验报告,仅供参考!!Activity界面基本实验;启动式service ,生成随机数;绑定式service,执行加法;广播:有序广播,系统广播,普通广播;contentprovider+SQLite;基于service的综合mp3;

2020-11-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除