算法笔记
Circle-C
这个作者很懒,什么都没留下…
展开
-
PAT中gets函数不能使用,用fgets、gets
If you want to read a string into a program, you must first set aside space to store the string and then use an input function to fetch the string.gets() only knows where the array begins, not how many elements it has.If the input string is too long, y...原创 2020-06-04 16:20:08 · 2033 阅读 · 0 评论 -
PAT B1008 数组元素循环右移问题 (20分) 三种解法
1008数组元素循环右移问题(20分)一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由(A0A1⋯AN−1)变换为(AN−M⋯AN−1A0A1⋯AN−M−1)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?输入格式:每个输入包含一个测试用例,第1行输入N(1≤N≤100)和M(≥0);第2行输入N个整数,之间用空格分隔..原创 2020-06-03 16:57:41 · 1183 阅读 · 0 评论 -
《算法笔记》第3章 入门篇(1)——入门模拟
简单模拟问题 A 剩下的树#include<stdio.h>#include<algorithm>using namespace std;int main(){ int L, M, sum, left, right, i; while(scanf("%d%d", &L, &M), L!=0){...原创 2020-03-04 15:17:53 · 327 阅读 · 1 评论 -
《算法笔记》第2章 C/C++快速入门
2.0.1 a+b#include<stdio.h>int main(){ int a, b; scanf("%d%d", &a, &b); printf("%d", a+b); return 0;}2.1.1 a+b#include<stdio.h>...原创 2020-02-04 15:22:46 · 4694 阅读 · 0 评论