- 博客(9)
- 收藏
- 关注
原创 给定一个正整数n,则n的三次方一定可以分解成n个连续的奇数
#include <cstdio>int main(){ int n; scanf("%d",&n); int a,b,c,sum; c = n*n*n ; a = 1; do{ sum = 0; b = a + (n-1)*2; sum = (a + b)*n/2; a = a + 2; }while(sum != c); for(in...
2018-02-21 11:59:32
3261
原创 关于%d%*c 与getchar()吃掉换行符问题
为什么要吃到换行符,因为在scanf使用%c输入时,会将换行符输入 **类似 2 string1 string2 这样的输入格式scanf(“%d”, &n)的话,还会有一个\n残留在标准输入中 这样的话第一个getline什么也读不到 ** 常见的有2中方法方法1:%d%*c作用时读取输入流中数字后的一个字符,并丢弃,使得后面的输入函数不能读到那个字符 方法2:getchar()
2017-04-13 00:21:09
2370
1
原创 pat甲级A1100
作者:王是王小明,仅用来记录自己的学习型经历,转载请表明出处 Actually this coding is not difficult ,the logic is very simple.Because the data volume is small,so the use of the STL’s map directly to establish a mapping table,the qu
2017-04-13 00:08:50
235
原创 pat甲级A1051 Pop Sequence
看书敲的代码,仅用来记录自己的成长#include <cstdio>#include <stack>using namespace std;const int maxn = 1010;int arr[maxn];stack<int> st;int main(){ int m,n,T; scanf("%d%d%d",&m,&n,&T); while(T--) { wh
2017-04-10 22:57:06
330
原创 ccf Markdown问题
ccf Markdown问题 (抄的网上的代码,手打增加记忆,并记录)#include <iostream>using namespace std;const int N=10010;int work1(string &res,string &str,int i);int work2(string &res,string &str,int i);int work1(string &res,
2017-04-10 22:54:13
293
原创 CCF学生排队
我是王小明,原创 **问题描述 体育老师小明要将自己班上的学生按顺序排队。他首先让学生按学号从小到大的顺序排成一排,学号小的排在前面,然后进行多次调整。一次调整小明可能让一位同学出队,向前或者向后移动一段距离后再插入队列。 例如,下面给出了一组移动的例子,例子中学生的人数为8人。 0)初始队列中学生的学号依次为1, 2, 3, 4, 5, 6, 7, 8; 1)第一次调整,
2017-04-09 22:01:28
1182
原创 ccf练习题分蛋糕
坚持做算法题,有的可能没有思路,看网上大佬做的,这里这记录下我的代码#include <iostream>#include <cstdio>using namespace std;int a[1001];int main(){ int n,k; cin>>n>>k; for(int i=0;i<n;i++) { cin>>a[i]; }
2017-04-09 00:46:43
716
原创 棋盘覆盖法
之前实验课老师让做棋盘覆盖的例子,附上代码,希望对IT感兴趣的人有帮助;#include <iostream>#include <cmath>using namespace std; int Board[100][100]; int tile=1;int main(){ int k,dr,dc; cin>>k; cin>>dr; cin>>dc;
2017-04-09 00:17:51
282
原创 蓝桥杯素数等差数列问题
ID:我是王小明 版权声明:本文为博主原创文章,未经博主允许不得转载。蓝桥杯素数等差数列问题问题描述:大体是长度为10的素数等差数列,求最小共差#include <iostream>#include <cstdio>#include <cmath>using namespace std;bool isPrim(int x) //判断素数函数 { if(x==2) return tr
2017-04-09 00:02:14
670
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人