摘要: 思路: 变量pre记录前一个数, cnt记录段数. 如果发现当前数与当前pre的值不同,段数+1. #include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n 阅读全文
posted @ 2019-07-10 17:51 域Anton 阅读(150) 评论(0) 推荐(0)
摘要: 思路: 先判断是不是闰年, 如果是, 使存月份天数的数组month二月的位置+1(即从28天变29天). 1 #include <iostream> 2 using namespace std; 3 int month[] {0, 31, 28, 31, 30, 31, 30, 31, 31, 30 阅读全文
posted @ 2019-07-10 17:45 域Anton 阅读(173) 评论(0) 推荐(0)
摘要: 思路1: 在输入时按照旋转后的矩阵将数字存入数组. 1 #include <iostream> 2 using namespace std; 3 4 int arr[1005][1005]; 5 6 int main() 7 { 8 ios::sync_with_stdio(false); 9 ci 阅读全文
posted @ 2019-07-10 17:14 域Anton 阅读(205) 评论(0) 推荐(0)
摘要: 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 struct pairs{ 6 int index; 7 int times; 8 }; 9 pairs arr[1005]; 10 11 bool cmp 阅读全文
posted @ 2019-07-10 17:06 域Anton 阅读(146) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 int arr[1005]; // 编号 4 int ocr[1005]{0}; // 第几次出现 5 int main() 6 { 7 ios::sync_with_stdio(false); 8 cin.tie(0); 9 10 int n; 11 ci... 阅读全文
posted @ 2019-07-10 16:32 域Anton 阅读(166) 评论(0) 推荐(0)
摘要: 思路1: 将每一条斜线作为一层, 可以证明一共有 n+n-1 层, 即 2*n-1 层. 再对每一层分别进行扫描. 扫描一层需要知道起点(终点通过起点、变换方式和矩形范围可以唯一确定)和扫描的方向(偶数层一个方向, 奇数层一个方向) 1 #include <iostream> 2 using nam 阅读全文
posted @ 2019-07-10 16:16 域Anton 阅读(186) 评论(0) 推荐(0)
摘要: 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int arr[1005]; 6 7 int main() 8 { 9 ios::sync_with_stdio(false); 10 cin.tie(nu 阅读全文
posted @ 2019-07-10 14:32 域Anton 阅读(168) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 bool vis[105][105]{false}; 7 int main() 8 { 9 ios::sync_with_stdio(false); 10 cin.tie(0); 11 int n; 12 cin >> ... 阅读全文
posted @ 2019-07-10 14:28 域Anton 阅读(208) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() 7 { 8 ios::sync_with_stdio(false); 9 cin.tie(0); 10 int n; 11 cin >> n; 12 set s; 13 for (i... 阅读全文
posted @ 2019-07-10 00:51 域Anton 阅读(160) 评论(0) 推荐(0)
摘要: #include #include using namespace std; struct form { int x1, y1, x2, y2; int id; int pri; }; form arr[15]; bool cmp (form a, form b) { return a.pri > b.pri; } int main() { ios... 阅读全文
posted @ 2019-07-10 00:46 域Anton 阅读(234) 评论(0) 推荐(0)
摘要: 思路: 可以用string类型变量直接存字符串,根据题目要求确定参与计算的九个数字对应下标,用一个check变量存给定字符串的最后一位转换的数字(注意check可能是X),用sum变量存计算好的结果. 将sum % 11和check比较,如果一致输出Right,不一致将字符串最后一位改为sum%11 阅读全文
posted @ 2019-07-10 00:22 域Anton 阅读(238) 评论(0) 推荐(0)
摘要: 题目: 思路: 利用一个数组记录每个数出现的次数(数组下标是出现的数,数组的值是出现数的次数). 边输入边统计,在统计的同时,用一个变量记录出现次数的最大值. 最后通过一次遍历(从最小的数开始),一旦发现出现次数与出现次数最大值相同的值,就输出数组下标. 需要分清楚数字的个数和数字的大小范围(数组大 阅读全文
posted @ 2019-07-10 00:04 域Anton 阅读(237) 评论(0) 推荐(0)