自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(47)
  • 资源 (2)
  • 收藏
  • 关注

原创 UVA 484 - The Department of Redundancy Department

水题,一个数组存数,一个数组存次数代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int Long=0,flag,n,x[10005],y[10005]; while(cin>>n) { flag=1; for(int i=0; i&l...

2018-05-17 13:22:06 382

原创 日期操作(面向对象)具体实现

将专栏中上一篇文章用面向对象的方式实现代码如下:#include <bits/stdc++.h>using namespace std;class Date{private: int year,month,day;public: Date(int year=0,int month=0,int day=0) { this->yea...

2018-05-16 17:14:15 311

原创 UVA 441 - Lotto

水题,暴力打表,直接上代码代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int flag=0,n,x[13]; while (cin>>n&&n) { if(flag) cout<<endl; ...

2018-05-05 19:44:05 247

原创 UVA 414 - Machined Surfaces

题意:第一行输入一个n,后面输入n行字符串,每行在左右x之间都存在一些空格,每次操作都使每行空格数减1,直到其中一行没有空格为止,求剩余的总空格数解法:可简化为求总空格数LongSum和最少空格数MinLong,结果即为LongSum-n*MinLong代码如下:#include <bits/stdc++.h>using namespace std;int main(){ ...

2018-05-05 11:02:25 226

原创 UVA 490 - Rotating Sentences

题意:将所给字符串顺时针旋转90度输出,水题,直接上代码代码如下:#include <bits/stdc++.h>using namespace std;char x[105][105];int main(){ int i=0,Max=0,Long,n; memset(x,0,sizeof(x)); while(cin.getline(x[i],105...

2018-05-05 10:23:40 150

原创 C/C++日期(结构体)操作具体实现

日期操作一般包含年增建,月增减,日增减,某一日期是该该年第几天和两日期间隔天数这几种问题我编了一道题模块化的实现了上述的功能,如下:设计一个程序,完成以下对日期的操作,包括以下函数:Date AddDay(Date d, int days):对日期增加days天数,然后返回得到的日期Date AddMonth(Date d, int months):对日期增加months月数,然后返回得到的日期D...

2018-05-03 16:49:18 2222 1

原创 UVA 384 - Slurpys

题意:根据所给要求,判断输入字符串是否满足要求代码如下:#include <bits/stdc++.h>using namespace std;char x[65];bool Slump(char x[65],int &i)//判断字符串是否符合Slump{ if((x[i]=='D'||x[i]=='E')&&x[++i]=='F') ...

2018-04-26 15:57:20 307

原创 UVA 444 - Encoder and Decoder

题意:输入一组字符串,若为数字字符串,逆序按ascII码解码输出,若为字母字符串,逆序输出ascII码代码如下:#include <bits/stdc++.h>using namespace std;const int M=85;char x[M];int main(){ char ch; int i,j,n=0; while((x[n++]=get...

2018-04-26 14:00:37 398

原创 UVA 492 - Pig-Latin

题意:若单词首字母为辅音放到最后输出,每个单词后加ay注意输入,我本想用gets,但一直ce,只好换成getchar了代码如下:#include <bits/stdc++.h>using namespace std;char x[1000005];bool A(char c)//判断是否为字母{ return ((c>='a'&&c<='z...

2018-04-24 13:27:22 791

原创 UVA - 458 The Decoder

天啊,这么水的题我竟然4次才ac==代码如下:#include <stdio.h>int main(){ char ch; while((ch=getchar())!=EOF) putchar((ch-'\n')?ch-7:ch); return 0;}

2018-04-23 19:25:23 244

原创 UVA 357 - Let Me Count The Ways

题意:给定一个总金额,用题中所给面额求有多少种分法解法:先打表,一个数组储存面额,一个数组储存从1到30000所有面额的分法数目,从最小面额开始,每次循环,某一金额的分法都加上比它小面额的金额的分法代码如下:#include <bits/stdc++.h>using namespace std;int value[5]= {1,5,10,25,50};const int M=3...

2018-04-23 19:12:56 187

原创 UVA 190 - Circle Through Three Points

题意:给出三点坐标,求过三点圆的标准方程和一般方程解法:已知两点(x1,y1)(x2,y2)求直线中垂线方程ax+by+c=0结论:a= x2-x1,b=y2-y1,c=(x1*x1-x2*x2+y1*y1-y2*y2)/2已知两直线方程a1x+b1y+c1=0,a2x+b2y+c2=0求交点结论: (  (b1*c2-b2*c1)/ (a1*b2-b1*a2)  ,  (c1*a2-c2*a1)...

2018-04-22 21:37:53 263

原创 UVA 438 - The Circumference of the Circle

题意:给出3点坐标,求过三点圆周长解法:用海伦公式求出三角形面积s,因为s=(1/2)absin(a.b),且根据正弦定理,2r=c/sin(a.b),得圆半径r=Πabc/(2s),进而解出圆周长代码如下:#include <bits/stdc++.h>using namespace std;const double pai=3.141592653589793;double ...

2018-04-22 19:38:57 335

原创 UVA 356 - Square Pegs And Round Holes

求圆的4分之1的结果乘4即可,比较点到圆心距离和半径代码如下:#include <bits/stdc++.h>using namespace std;int n;double A(int x,int y){ return sqrt((n-x)*(n-x)+(n-y)*(n-y));}int main(){ int n,a,b,i,j,flag=0; ...

2018-04-19 18:28:07 494

原创 UVA 105 - The Skyline Problem

代码如下:#include <bits/stdc++.h>using namespace std;int x[10005];int main(){ int a,b,c,d=0,i; memset(x,0,sizeof(x)); while(cin>>a>>b>>c) { if(c>d)...

2018-04-19 18:04:31 299

原创 UVA 455 - Periodic Strings

代码如下:#include <bits/stdc++.h>using namespace std;char x[85];int main(){ int n,i,j,l; while(cin>>n) while(n--) { cin>>x; l=st...

2018-04-19 17:37:11 258

原创 UVA 160 - Factors and Factorials

遍历打表,这题真诡异,我一直WA,把两个100改成101就AC了,还是不清楚有什么区别,谁能帮帮我啊代码如下:#include <bits/stdc++.h>using namespace std;int y[105];void A(int x[])//遍历打表所有100以内质数{ int i,j,k; for(i=2,j=0; i<=101; ++i)...

2018-04-19 16:33:40 363

原创 UVA 343 - What Base Is This?

先求出两个数分别满足的最小进制,之后两个数从最小进制开始判断两数在10进制下是否相等代码如下:#include <bits/stdc++.h>using namespace std;int BaseChange(int base, char m[])//从给定进制转化到十进制{ int a=0,b; for(int i=0; m[i]; ++i) {...

2018-04-19 14:42:32 432

原创 UVA 368 - Perfect Cubes

将200以内数的三次方打表,四重循环暴力判断代码如下:#include <bits/stdc++.h>using namespace std;int x[205];int main(){ for(int i=1;i<=200;++i) x[i]=i*i*i; for(int a=6;a<=200;++a) for(i...

2018-04-19 13:57:41 282

原创 UVA 445 - Marvelous Mazes

题意看output就差不多理解了代码如下:#include <bits/stdc++.h>using namespace std;int main(){ char ch; int number=0; while((ch=getchar())!=EOF) { if(ch>='0'&&ch<='9') ...

2018-04-19 13:40:41 166

原创 UVA 102 - Ecological Bin Packing

暴力枚举嘤嘤嘤用0表示B,1表示G,2表示C代码如下:#include <bits/stdc++.h>using namespace std;int name[6][3]= {0,2,1,0,1,2,2,0,1,2,1,0,1,0,2,1,2,0};int main(){ int x[3][3],i,j,y,Min; while(cin>>x[0...

2018-04-14 23:36:43 248

原创 UVA 440 - Eeny Meeny Moo

约瑟夫环问题,与UVA 151几乎一样,只是把第2个变为第13个详见UVA 151 - Power Crisis代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int x,y,i,j; while(cin>>x&&x) for(i=1;; ++...

2018-04-14 21:50:25 417

原创 UVA 151 - Power Crisis

  约瑟夫环变形题因为第一次关第一个,所以可以转化为N-1个电厂,最后留下第12个电厂的问题代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int x,y,i,j; while(cin>>x&&x) for(i=1;; +...

2018-04-14 21:39:22 313

原创 UVA 167 - The Sultan's Successors

八王后问题,回溯算法代码如下:#include <bits/stdc++.h>using namespace std;int number=0,x[10],y[100][10];void D()//存储王后位置 { for(int i=1; i<=8; i++) y[number][i]=x[i]; number++;}int ...

2018-04-14 19:59:36 354

原创 UVA 750 - 8 Queens Chess Problem

经典的八王后问题,回溯算法代码如下:#include <bits/stdc++.h>using namespace std;int number=0,x[10],y[100][10];void D()//存储王后位置{ int i; for(i =1; i <=8; i++) y[number][i]=x[i]; number...

2018-04-12 19:13:34 692

原创 UVA 305 - Joseph

约瑟夫环问题,要在输入之前用一个数组列出所有结果,这样调用不会tle代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int k,i,a,b,j,x[15],s; for(k=1; k<14; ++k) { for(i=k+1;; ++i) {...

2018-04-12 16:17:49 277

原创 CODEFORCES - 146B Lucky Mask

一开始想使用ultoa函数,发现编译器不支持,最后还是妥协了,用循环把数放到数组中,写完我都不敢相信自己ac了,我以为铁定超时了代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int a,b,c,d,m,n; int x[10],y[10]; int i,j,k; whi...

2018-04-08 21:37:10 431

原创 DHUOJ - 2017060311 Problem K - Treasure Map

记得大一上学期做oj时遇到过这种螺旋矩阵的问题,当时刚学数组,做了一天才做出来,现在做这道更难一些的题很快就ac了,果然人是很进步的啊,嘤嘤嘤只需用4个变量确定上下左右四个边界,再用一个递归函数即可代码如下:#include <bits/stdc++.h>using namespace std;const int M=10005;int x[M],y[105][105];v...

2018-04-05 17:16:03 184

原创 DHUOJ - 2017060309 Problem I - Frog's Jumping

乍一看还以为是一道约瑟夫环的题,看来我眼瞎了开始的算法超时了#include <bits/stdc++.h>using namespace std;const int b=1000005;int y[b];int main(){ int n,a,k,x,i; while(cin>>n) { a=1; fo...

2018-04-05 15:47:16 161

原创 DHUOJ - 2017060307 Problem G - One for You

在n+m为偶数或n-m的绝对值为大于1的奇数时,Bob有绝对优势代码如下:#include <iostream>using namespace std;int A(int a){ return a<0?(-a):a;}int main(){ int x,y,z; while(cin>>x>>y) { ...

2018-04-05 14:37:31 165

原创 DHUOJ - 2017060305 Problem E - Find Palindrome

找到最长回文数并输出长度代码如下:#include <iostream>#include <cstring>using namespace std;int main(){ char x[55]; int n,a,b,i,j; while(cin>>x) { n=strlen(x); b=...

2018-04-05 14:16:33 169

原创 DHUOJ - 2017060313 Problem M - 2D Convolution

注意定义数组使用long long型,不然会wa哦。代码如下:#include <iostream>using namespace std;int main(){ int n,m,i,j,a,b; long long D[105][105],K[8][8],C[105][105]; while(cin>>n>>m) {...

2018-04-05 12:49:58 159

原创 DHUOJ - 2017060315 Problem O - An Easy Problem

此题注意使用long long,不然会造成数据溢出。代码如下:#include <iostream>#include <algorithm>using namespace std;long long A(long long a){ return a<0?(-a):a;}int main(){ long long a,x[20005],i,...

2018-04-05 12:00:37 183

原创 DHUOJ - 2017060301 Problem A - STEED Cards

题意:STEED排序有60种排法,按照字典排序输出所需序列代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int n=0,i,a; char x[5]= {'S','T','E','E','D'},y[60][5]; sort(x,x+5); do { ...

2018-04-02 12:01:12 217

原创 CODEFORCES - 864C Bus

需要特别讨论最后一次行程的情况代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int a,b,f,k,c,number; while(cin>>a>>b>>f>>k) { c=b-f; //c表示剩余油量 ...

2018-04-02 11:20:33 210

原创 CODEFORCES - 864B Polycarp and Letters

题意:在两个大写字母之间,第一个大写字母之前或是最后一个大写字母之后最多有几个不同的小写字母代码如下:#include <bits/stdc++.h>using namespace std;int main(){ int a,m,n,i; char x[205],y[31]; while(cin>>a) { cin&...

2018-04-01 23:39:06 188

原创 CODEFORCES - 864A Fair Game

题意:一人取一个数,两个人所取包含所有数且所取相同则YES,并输出两人的数,否则NO。代码如下:#include <iostream>using namespace std;typedef struct number{ int a[100]; int b[100];}NUM;int main(){ NUM p; int i,j,k,temp...

2018-04-01 22:19:18 215

原创 UVA 694 - The Collatz Sequence

经典的3n+1题,注意使用long long防止数据溢出。代码如下:#include <iostream>#include <iomanip>using namespace std;int A(long long a,long long b){ int n=0; while(a-1) //使用三目运算符进行判断,循环直到1为止 { ...

2018-03-22 15:17:18 423

原创 UVA 371 - Ackermann Functions

同uva100,也是经典的3n+1问题,注意本题数字1运行3次,博主因为这个5次WA,很难受代码如下:#include <iostream>using namespace std;int A(long long a){ int n=0; if(a==1) return 3; while(a-1) //使用三目运算符进行判断,循环直到1为...

2018-03-22 14:58:02 359

原创 UVA 100 - The 3n + 1 problem

题意分析:在输入的两个数之间找到循环次数最大的数所对应的次数,循环要求,若为奇数,乘3后加1,若为偶数,除以2,直到1为止。代码如下:#include <iostream>#include <iomanip>using namespace std;int A(int a){    int n=0;    while(a-1)  //使用三目运算符进行判断,循环直...

2018-03-22 14:24:36 864

东华大学汇编实验报告1+2

东华大学罗辛老师的汇编课程实验报告1+2解答,分享给有需要的朋友

2018-12-24

东华大学汇编实验3

罗辛老师的汇编课程上机实验报告,分享给有需要的朋友

2018-12-24

空空如也

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

TA关注的人

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