
其他程序设计题目
其他无分类的程序设计题目
han_hhh
这个作者很懒,什么都没留下…
展开
-
求不确定度
一个很简单的程序,求不确定度输入这一组数据的个数n,以及仪器的误差dif和c,//输入n个数据#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;int main(){ int n; wh...原创 2018-10-25 22:39:40 · 3007 阅读 · 0 评论 -
图的存储
图中任意两点都有路径连接的叫连通图,没有圈的连通图叫数,有向图的边数等于顶点数-1,无向图的顶点数等于边数。有向图分出度(这个顶点出去的边数)和入度(进来的边数)用程序表示图的方法有两种,邻接矩阵和邻接表;邻接表分两种:一种使用vectorstruct edge{ int to,cost;};vector<edge>G[MAXV];struct ...原创 2018-10-13 22:38:10 · 157 阅读 · 0 评论 -
关于ASCLL
基础不扎实!!!1.得到一个字符的ascll 码值:char ch;cin>>ch;cout<<(int)ch;2.比较字符串的ascll思路:1.从第一个字符开始比较,如果a字符串的第n个字符的ascll码值>b字符串的第n个字符的ascll码值,则a>b;反之a<b,若相等继续比较下一位;2.若a和b长度相等且每个字符都相同,则a=b;3.若a是b...原创 2018-06-04 20:49:07 · 892 阅读 · 3 评论 -
I. Reversion Count
I. Reversion CountDescription:There is a positive integer X, X's reversion count is Y. For example, X=123, Y=321; X=1234, Y=4321. Z=(X-Y)/9, Judge if Z is made up of only one number(0,1,2...9), don't ...原创 2018-04-22 14:01:30 · 208 阅读 · 3 评论 -
c++中常用函数及头文件
algorithm:排序:sort(a,a+10) //第三个参数不写,为从小到大排若要从大到小排:需要加入一个比较函数bool compare(int a,int b){return a>b;}使用时:sort(a,a+10,compare)Sort函数有三个参数:(1)第一个是要排序的数组的起始地址。(2)第二个是结束的地址(最后一位要排序的地址的下一地址)(3)第三个参数是排序...原创 2018-03-18 11:01:56 · 1980 阅读 · 0 评论 -
C语言中常用函数及头文件
stdlib.h:求整数的绝对值:abs() strcmp:排序:qsort()ctype.h:判断是否为数字:isdigit()判断是否为字母:isalpha()判断是否为小写字母:islower()判断是否为大写字母:isupper()变小写:toupper()变大写:tolower()string.h: 字符串长度:strlen(s)数组清零:mem...原创 2018-03-03 11:47:25 · 10549 阅读 · 7 评论 -
判断回文字符串
栈:(后进先出)限定为只能在一端进行插入和删除操作题目:“xyzyx”是一个回文字符串,所谓回文字符串就是指正读反读均相同的字符序列,如“席主席”、“记书记”、“aha”和“ahaha”均是回文,但“ahah”不是回文。输入:一个字符串;输出:若为回文字符则输出YES,否则输出NO;#include<stdio.h>#include<string.h>int main(...原创 2018-03-02 17:52:42 · 2882 阅读 · 0 评论 -
解密QQ号
队列:队列是一种特殊的线性结构。出队:在队列的头部(head)进行删除操作。入队:在队列的尾部(tail)进行插入操作。当队列中没有元素时(即 head==tail),称为空队列。规则:首先将第 1个数删除,紧接着将第 2 个数放到这串数的末尾,再将第 3 个数删除并将第 4 个数放到这串数的末尾,再将第 5 个数删除……直到剩下最后一个数,将最后一个数也删除。按照刚才删除的顺序,把这些删除的数连...原创 2018-03-02 16:36:44 · 2765 阅读 · 0 评论 -
字符串中的数字
输入一个字符串,长度不超过20,字符串中包含数字和非数字字符,将其中是数字的字符提取出来,对它们进行从小到大排序,非数字字符则忽略不计。Input若干行字符串Output每一个字符串中所有数字的升序排序。每个数字占四个字符位置。使用cout<< setw(4)<< num; 处理完一行字符串换行一次。使用cout<< endl;Sample Input31W 7...原创 2018-02-24 20:56:46 · 613 阅读 · 0 评论 -
用户和用户组管理
usermod -a -G demo xiaohan将已经存在的用户xiaohan加入到demo组中useradd -g demo dahan将原先不存在的用户dahan创建并加入到demo组中groups xiaohan查看用户xiaohan所在的用户组members demo查看组demo中的用户gpasswd -d xiaohan demo将...原创 2019-07-26 17:31:19 · 97 阅读 · 0 评论 -
开机自动配置IP【Shell】
https://blog.youkuaiyun.com/tjk296862380/article/details/48318791对以上博文的注释 line_num=$(cat /etc/sysconfig/network-scripts/ifcfg-eth0 | wc -l)//读取文件/etc/sysconfig/network-scripts/ifcfg-eth0运行语句,输出的结...原创 2018-12-28 16:43:41 · 672 阅读 · 0 评论 -
2018徐州模拟赛-I:Characters with Hash
1000ms 262144KMur loves hash algorithm, and he sometimes encrypt another one's name, and call him with that encrypted value. For instance, he calls Kimura KMR, and calls Suzuki YJSNPI. One day he ...原创 2018-09-10 08:25:56 · 259 阅读 · 0 评论 -
2018徐州模拟赛-H-Ryuji doesn't want to study
1000ms 262144KRyuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book has its knowledge a[i]a[i].Unfortunately, the longer he learns, the fewe...原创 2018-09-10 08:27:29 · 340 阅读 · 0 评论 -
2018沈阳模拟赛-K
这道题很费劲的将所有superme number找了出来,发现317以后就再也没有该数了1,2,3,5,7,11,13,17,23,31,37,53,71,73,113,131,137,173,311,317这个过程过了很久没写字符串的题,字符串的知识又糊了。输入一串很长的数,可以用一个char型数组n,直接scanf(“%s”,n);n[i]-'0'只能把某一位转化成整型数,不能把一...原创 2018-09-08 22:56:45 · 168 阅读 · 0 评论 -
HDU1014 POJ1597 Uniform Generator
Computer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the form seed(x+1) = [ seed(x) + STEP ] % MOD where "%" is the modulus...原创 2018-08-25 10:25:26 · 204 阅读 · 0 评论 -
POJ 2234 Matches Game
Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can choose a pile and take away arbitrary number of matches from...原创 2018-08-24 11:55:22 · 579 阅读 · 0 评论 -
POJ1852 UVA10714 ZOJ2376 Ants
AntsTime Limit: 1000MS Memory Limit: 30000K Total Submissions:24497 Accepted: 9798 DescriptionAn army of ants walk on a horizontal pole of length l cm, each with a constant spe...原创 2018-08-24 10:42:32 · 220 阅读 · 0 评论 -
UVA10037 Bridge
n people wish to cross a bridge at night. A group of at most two people may cross at any time, andeach group must have a flashlight. Only one flashlight is available among the n people, so some sort o...原创 2018-08-15 19:49:22 · 407 阅读 · 1 评论 -
POJ 2661 Factstone Benchmark
Amtel has announced that it will release a 128-bit computer chip by 2010, a 256-bit computer by 2020, and so on, con- tinuing its strategy of doubling the word-size every ten years. (Amtel released a ...原创 2018-08-14 18:28:54 · 258 阅读 · 0 评论 -
Smallest Difference
Smallest DifferenceTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 15423 Accepted: 4173DescriptionGiven a number of distinct decimal digits, you can form one integer by choosing a non-empty ...原创 2018-07-15 21:45:54 · 204 阅读 · 2 评论 -
next_permutation
next_permutation:stl中提供的计算下一个排列的算法全排列实现代码#include<iostream>#include<algorithm>using namespace std;int main(void){ int a[4]={1,2,3}; do{ cout<<a[0]<<a[1]<&...原创 2018-07-15 20:13:33 · 1330 阅读 · 0 评论 -
Jungle Roads
Jungle RoadsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 30648 Accepted: 14347DescriptionThe Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was...原创 2018-07-15 17:33:45 · 1917 阅读 · 0 评论 -
1.g Duizi and Shunzi
Nike likes playing cards and makes a problem of it. Now give you n integers, ai(1≤i≤n)ai(1≤i≤n) We define two identical numbers (eg: 2,22,2) a Duizi, and three consecutive positive integers (eg: 2,3,4...原创 2018-07-14 23:28:52 · 223 阅读 · 0 评论 -
1.a A Math Problem
You are given a positive integer n, please count how many positive integers k satisfy kk≤nkk≤n. InputThere are no more than 50 test cases. Each case only contains a positivse integer n in a line. 1≤n≤...原创 2018-07-14 11:06:06 · 243 阅读 · 1 评论 -
银行账户管理程序(二)
1、为savingaccount增加一个静态数据成员total来记录各个账户的总金额,相应的静态成员函数getTotal用来对其访问。2、将getbalance,accumulate这些成员函数改为常成员函数3、将SavingAccount类从主函数所在的源文件中分开,建立两个新文件account.h和account.cpp,分别存放在SavingAccount类的定义和实现。//整个程序分为三个...原创 2018-06-18 14:57:37 · 3536 阅读 · 0 评论 -
银行账户管理系统(一)
根据所学知识代码持续完善中……#include <iostream>#include<cmath>using namespace std;class SavingAccount{private: int id; //账户 double balance; //余额 double rate; ...原创 2018-06-18 14:00:51 · 9471 阅读 · 0 评论 -
floor、ceil和round函数
头文件为cmathfloor函数是向下取整函数,用来得到不大于一个数的最大整数;如果需要对一个数进行四舍五入取整,floor(x+0.5)可实现ceil函数是向上取整函数,用来得到不小于一个数的最小整数...原创 2018-06-18 14:11:01 · 2011 阅读 · 1 评论 -
学生类
(1).输出每个学生的姓名、学号、成绩;(2)统计并输出学生的总人数、总成绩、平均成绩、最高成绩、最低成绩。不知道为什么让b=a会报错#include<iostream>#include<math.h>#include<cstdlib>using namespace std;class Student{public: Student(strin...原创 2018-06-12 09:33:07 · 531 阅读 · 1 评论 -
类与对象课后题
一个用于人事管理的人员类,所有人员都具有的属性有:编号,性别,出生日期,身份证号,录入并输出这些数据,其中出生日期声明为一个Date类内嵌子对象c++一个伟大的起步……#include <iostream>using namespace std;class Date{ //日期类public: Date(){} //默认构造函数,注意末尾没有“;...原创 2018-06-09 16:32:07 · 383 阅读 · 0 评论 -
汉诺塔问题
有三根针A、B、C。A针上有N个盘子,大的在下,小的在上,要求把这N个盘子从A针移到C针,在移动过程中可以借助B针,每次只允许移动一个盘,且在移动过程中在三根针上都保持大盘在下,小盘在上。分析:将n 个盘子从A针移到C针可以分解为下面三个步骤:①将A 上n-1个盘子移到 B针上(借助C针);②把A针上剩下的一个盘子移到C针上;③将n-1个盘子从B针移到C针上(借助A针);事实上,上面三个步骤包含两...原创 2018-06-06 20:37:38 · 394 阅读 · 0 评论 -
用泰勒展开式求数学量(三角函数,e^x)
用泰勒展开式arctanx=x-x^3/3+x^5/5-x^7/7+.......#include<iostream>using namespace std;double arctan(double x){ double sqr=x*x; double e=x; double r=0; int i=1; while(e/i>1e-15)...原创 2018-06-06 17:23:42 · 6198 阅读 · 0 评论 -
2018.05.19 A:贝壳找房性价比
思想:联系所学数学知识,要求的式子的意义可以把p看成纵坐标,把s看成横坐标,然后求两点连线斜率的最大值。在多个点中找斜率最大的两个点的直线若进行二重循环用两个for会超时,想别的方法,先将各个点按横坐标进行排序,然后相邻两点连线斜率的最大值即为所求。用sort函数先进行排序#include<iostream>#include<algorithm>#include<...原创 2018-05-19 21:10:02 · 552 阅读 · 2 评论 -
2018.05.19 B. 贝壳找房户外拓展(简单)
1000ms 262144K贝壳找房的销售顾问每天要带客户看很多房源,这对他们来说是一件体力活,所以他们要经常进行户外拓展来增强体力。这一次他们进行的拓展是在一个 n \times mn×m 的矩形地图方格地图上玩游戏,最初,地图是空的。游戏一共进行 qq 轮,第 ii 轮,会是以下操作之一假设在这之前有 k-1k−1 次 11 操作,在 (l,y)(l,y) 到 (r,y)(r,y) 线段之间...原创 2018-05-19 21:10:59 · 352 阅读 · 1 评论 -
数据结构 编程实验 第一篇
1.那个过了好多遍都过不了的wrong answer我也不知道这个end of line 是什么鬼,,,但是他后边说不要有空格和其他东西,所以不写\n;2.#include <stdio.h>int a[1000];int main(void){ int i,j,n,count; //不能在此处定义count=0;因为下...原创 2018-03-22 22:34:05 · 129 阅读 · 4 评论 -
1004 Counting Leaves (30分)
1004 Counting Leaves (30分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts with a line containing 0<原创 2020-07-25 09:25:19 · 130 阅读 · 0 评论 -
Head of a Gang【浙江大学复试上机题】【并查集】
题目描述One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone calls made b原创 2020-07-13 23:53:50 · 266 阅读 · 0 评论 -
1002 A+B for Polynomials (25分)
题目大意输入两行,每行格式如上,K为多项式中非零项的个数,N为指数,aN为该项的系数。最后输出两个多项式的和思路:用一个结构体数组 ploy,数组中的每个元素存储该项的指数和系数。将两个多项式的所有项都加入到数组中,按指数从大到小的顺序排列数组中的每个元素,排列完成后,遍历数组,下标为0~K1+K2-1,看第i项与i+1项是否指数相同,若相同,在基础上加上i+1项的系数,若不相同,存储到备用数组,准备输出注意:1.输出格式:每一行末尾没有多余的空格,多项式的系数保留一位小数;只输原创 2020-05-25 17:43:13 · 1330 阅读 · 0 评论 -
1001 A+B Format (20分)
要注意的几点1、0+0的情况单独处理2、负数要把符号存下来,并把负数装化为正数方便后续除法运算3、避免输出-,999,991这种情况,处理方法是在加小数点的时候判断一下#include<iostream>using namespace std;int main() { int a,b; char res[10]; cin>>a>>b; int c=a+b; if(c==0) { //0+0 cout<<"0"<原创 2020-05-24 21:21:06 · 98 阅读 · 0 评论 -
压缩BCD码拆成两个ACSII码存入指定单元【汇编语言】
将片内RAM的20H单元中的压缩BCD码拆成两个ACSII码存入21H、22H单元。低4位存在21H单元,高4位存在22H单元。思路:压缩BCD码和非压缩BCD码的区别一个BCD码占4位,而一个字节有8位。若把两个BCD码放在一个字节中,就叫压缩的BCD码; 压缩BCD码的每一位用4位二进制表示,一个字节表示两位十进制数。例如10010110B表示十进制数96D;而一个字节只放一个...原创 2020-03-19 14:59:08 · 5737 阅读 · 4 评论 -
Oulipo POJ - 3461【KMP】
在KMP模板上的改动是 if(j==len1){// printf("i=%d j=%d\n",i,j); num++; j=nextTable[j];#include<iostream>#include<string> using namespace std;string p,t;int nextTable[10005...原创 2020-05-08 11:42:46 · 173 阅读 · 0 评论