
笔记
LIANG~~
Hello world.
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
《java作业》
/*java.util:java的实用工具包,里面包含了用于解决某些问题而实现的工具类public:访问权限最高static:静态,表示加载类的时候主函数就已经存在了void:表示主函数不返回任何值main:不是一个关键字,但是一个特殊单词能被虚拟机所识别String[] args: 表示主函数所带的参数为数组,数组名为args*//*Scanner:用于扫描输入文本的类名input:声明的变量名new Scanner():给变量input分配空间,初始化,实例化System.in原创 2022-03-19 10:01:20 · 502 阅读 · 0 评论 -
《程序设计实践》——等差数列
#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;const int N=10000;int main(void){ int d; int n; scanf("%d",&n); int a[N]; for(int i=0; i<n; i++) { scanf("%d",&a[原创 2021-12-16 19:16:55 · 406 阅读 · 0 评论 -
《程序设计实践》——包子凑数
#include<bits/stdc++.h>using namespace std;int N, A[110];//两个互质的数a,b 最大不能组合数为a*b-a-bbool dp[10000]={false}; //dp[i]表示i可不可以被凑出//辗转相除法,求最大公约数int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int main(void){ int ans=0原创 2021-11-25 10:42:34 · 337 阅读 · 0 评论 -
《程序设计实践》——祥瑞生辉
/* aa[4] aa[3] aa[5] aa[6] + aa[0] aa[1] aa[2] aa[3] ----------------------------- aa[0] aa[1] aa[5] aa[3] aa[7]*/#include<iostream>#include<algorithm>using namespace std;int main(){ int aa[10]={0,1,2,3,4,5,原创 2021-10-28 10:52:37 · 135 阅读 · 0 评论 -
《程序设计实践》——楼房距离
#include<math.h>#include<stdio.h>int main(void){ int w,m,n; int rm,rn,cm,cn; int d=0; scanf("%d %d %d",&w,&m,&n); //m的行数rw if(m%w==0) rm=m/w; else rm=(m/w)+1; printf("rm %d\n",rm);.原创 2021-10-28 09:23:52 · 115 阅读 · 0 评论 -
《程序设计实践》——牌型种数
#include<stdio.h>int num=0; //表示种类个数//n表示每次选择point点牌的数量//point表示牌的点数//sum为13,每个人发13张牌void card(int n,int point,int sum){ sum+=n; //递归结束条件 if(sum==13) { num++; sum=0; return; } if(sum>13)原创 2021-10-26 09:27:15 · 109 阅读 · 0 评论 -
《程序设计实践》——李白打酒
#include<stdio.h>int s=0;void buywine(int flower,int shop,int c) //c:酒的容量{ if(flower==1 && shop==0 && c==1) //由于最后一次是遇花,还未减去1 { s++; return; } if(flower>0) buywine(flower-1,shop,c-1原创 2021-09-30 10:21:41 · 216 阅读 · 0 评论 -
《程序设计实践》——39级台阶
#include<stdio.h>int count=0; //全局变量countvoid sum(int n,int step){ if(n<0) return; if(n==0 && step%2==0) { count++; //解的个数增加 return; } sum(n-1,step+1); sum(n-2,step+1);}int main(原创 2021-09-30 09:04:50 · 95 阅读 · 0 评论 -
《程序设计实践》——快速排序(蓝桥杯)
#include<stdio.h>void swap(int a[],int i,int j){ int t=a[i]; a[i]=a[j]; a[j]=t;}int partition(int a[],int p, int r){ int i=p; int j=r+1; int x=a[p]; while(1){ while(i<r && a[++i]<x); wh原创 2021-09-16 10:18:14 · 129 阅读 · 0 评论 -
《程序设计实践》——三部排序
#include<stdio.h>void sort3p(int *x,int len) //x是指向待排序的整形数组,len是数组的长度{ int mod=0; int left=0; int right=len-1; while(mod<=right) { if(x[mod]<0){ int t=x[left]; x[left]=x[mod];原创 2021-09-14 11:13:04 · 100 阅读 · 0 评论 -
《程序设计实践》——连号区间数
#include<stdio.h>int main(void){ int N; int arr[5000]={0}; int i,j,max,min; int count=0; scanf("%d",&N); for(i=0; i<N; i++) { scanf("%d",&arr[i]); } for(i=0; i<N-1; i++) { max=a原创 2021-09-10 16:51:01 · 102 阅读 · 0 评论 -
《程序设计实践》——马虎的算式
#include<stdio.h>int main(void){ int n=0; int a,b,c,d,e; for(a=1; a<10; a++) { for(b=1; b<10; b++) { if(b!=a) for(c=1; c<10; c++) { if(c!=a && c!=b)原创 2021-09-10 15:56:20 · 85 阅读 · 0 评论 -
《程序设计实践》——高斯日记
#include<stdio.h>int main(void){int y=1777;int m=4;int d=30; for(int n=1; n<8113; n++) { d++; if(m==12 && d==32) { y++; m=1; d=1; continue; }原创 2021-09-09 10:40:45 · 117 阅读 · 0 评论 -
MATLAB笔记
。原创 2021-06-10 10:04:23 · 76 阅读 · 0 评论 -
MATLAB笔记
除法运算有右除 / 和 左除 若A矩阵是非奇异矩阵,B/A等效于B*inv(A)inv(),矩阵求逆乘方运算要求A为方阵A^2点运算点运算符:.* ./ .\ .^指对应元素进行相应运算,要求矩阵同型关系运算关系运算符:> < >= <= == ~=逻辑运算逻辑运算符:& | ~1.7字符串的处理字符串的表示xm=' Hello World '字符串中有单引号,则用..原创 2021-06-08 09:32:39 · 411 阅读 · 0 评论 -
贪心法———TSP问题
#include<stdio.h>#define INF 999using namespace std;const int n=5;int TSP(int arc[n][n], int w) //从顶点w出发{ int edgeCount=0, TSPLength=0; int min,u,v; int flag[n]={0}; //顶点均未加入哈密顿回路 u=w; flag[w]=1; //将点w加入哈密顿回路 whil原创 2021-06-06 17:19:58 · 979 阅读 · 0 评论 -
动态规划法———01背包问题
#include<stdio.h>int KnapSack(int w[], int v[], int n, int C);int max(int a, int b);int V[100][100];int main(void){ int w[6]={0,2,2,6,5,4}; int v[6]={0,6,3,5,4,6}; int n=5; int C=10; int s=0; s=KnapSack(w,v,n,10); p原创 2021-06-04 20:20:37 · 141 阅读 · 0 评论 -
动态规划法———最长递增子序列问题
#include<iostream>using namespace std;int IncreaseOrder(int a[],int n);int main(void){ int a[10]={5,2,8,6,3,6,9,7}; IncreaseOrder(a,10);}int IncreaseOrder(int a[],int n){ int i,j,k,index; int L[n],x[n][n]; for(i=0; i<n原创 2021-05-30 19:54:48 · 572 阅读 · 0 评论 -
动态规划法———多源点最短路径问题(Floyd算法)
#include<iostream>#define INF 999using namespace std;const int n=3;void Floyd(int arc[n][n],int dist[n][n]){ int i,j,k; int path[9][3]={0}; for(i=0; i<n; i++) //初始化矩阵dist { for(j=0; j<n; j++) {原创 2021-05-22 10:43:38 · 1167 阅读 · 0 评论 -
Matlab教程实操笔记
gghjjj#include<stdio.h>原创 2021-05-17 14:57:37 · 126 阅读 · 0 评论 -
《C Primer Plus》第三章练习题———c语言基本数据类型
1.通过实验,观察系统如何处理整数上溢,浮点数上溢和下溢的情况#include<stdio.h>int main(void){ //整数上溢 int a=2147483647; //32位机器下int的取值范围(-2^31~2^31-1) printf("整数上溢:%d\n",a+1); printf("整数上溢:%d\n",a+2); //浮点数上溢 float toobig=3.4E38*100.0f; printf(原创 2021-05-09 10:49:28 · 235 阅读 · 0 评论 -
《c语言程序设计》题目集———查询水果价格
#include<stdio.h>#include<stdlib.h>int main(void){ float r[]={3.00,2.50,4.10,10.20}; int n; printf("[1] apple\n[2] pear\n[3] orange\n[4] grape\n[0] exit\n"); for(int i=0; i<5; i++) { scanf("%d",&n);原创 2021-05-01 19:49:16 · 2969 阅读 · 0 评论 -
蛮力法———百元买百鸡
/*百元买百鸡问题*/#include<stdio.h>void chicken();main(){ chicken();}void chicken(){ int x,y,z; int count=0; for(x=0; x<=20; x++) { for(y=0; y<=33; y++) { z=100-x-y; if((z%3==0) && (原创 2021-04-24 09:40:49 · 662 阅读 · 0 评论 -
《C Primer Plus》第一章习题———初识C语言
第1章第原创 2021-04-24 08:23:31 · 186 阅读 · 0 评论 -
《c语言程序设计》题目集———生成3的乘方表
/*输入一个非负整数n,生成一张3的乘方表,输出3^0~3^n的值。可调用幂函数计算3的乘方。*/#include<stdio.h>#include<math.h>main(){ int n; int s; scanf("%d",&n); for(int i=0; i<=n; i++) { s=pow(3,i); printf("pow(3,%d) = %d\n",i,s);原创 2021-04-22 10:23:45 · 751 阅读 · 0 评论 -
减治法———二叉查找树(未完成)
/*二叉查找树*/#include<iostream>//定义几个结构体struct BiNode //定义一个结构体{ int data; BiNode *lchild,*rchild;} //在二叉树插入节点BiNode *InsertBST(BiNode *root,int data){ if(root==NULL) { root=new BiNode; //为data申请一个新节点 root->原创 2021-04-20 19:47:44 · 232 阅读 · 0 评论 -
减治法———折半查找
/*折半查找*/#include<stdio.h>int BinSearch(int r[], int n, int k);main(){ int A[]={7,14,18,21,23,29,31,35,38}; int k=14; int s=0; s=BinSearch(A,9,14); printf("待查序列是:"); for(int i=0; i<9; i++) { printf("%d ",A[原创 2021-04-19 19:39:41 · 561 阅读 · 0 评论 -
减治法———两个序列的中位数
/*两个序列的中位数*/#include<stdio.h>int SearchMid(int A[], int B[], int n);main(){ int A[]={11,13,15,17,19}; int B[]={2,4,10,15,20}; int s=0; //打印A,B序列 printf("序列A是:"); for(int i=0; i<5; i++) { printf("%d ",A[i]);原创 2021-04-19 19:21:18 · 573 阅读 · 0 评论 -
分段函数
#include<stdio.h>#include<math.h>main(){ float x=0; float y=0; scanf("%f",&x); if(x>=0) { y=sqrt(x); printf("f(%.2f) = %.2f",x,y); } if(x<0) { y=pow((x+1),2)+2*x+(1/x);原创 2021-04-15 11:05:11 · 203 阅读 · 0 评论 -
计算物体自由下落距离
/*一个物体从100米的高空自由落下。编写程序,求它在前3秒内下落的垂直距离。设重力加速度为10米/秒2。*/#include<stdio.h>main(){ float height=0; int g=10; int t=3; height=t*t*g/2.0; printf("height = %.2f",height);}笔记:%m.n f,指定输出的数据占m列,其中有n位小数。如果数值长度小于m,则左端补空格,若数值长度原创 2021-04-15 10:06:56 · 1248 阅读 · 0 评论 -
华士摄氏温度转换
本题要求编写程序,计算华氏温度150°F对应的摄氏温度。计算公式:C=5×(F−32)/9,式中:C表示摄氏温度,F表示华氏温度,输出数据要求为整型。#include<stdio.h>main(){ int fahr=0; int celsius=0; scanf("%d",&fahr); celsius=5.0*(fahr-32)/9.0; printf("fahr = %d, celsius = %d",fahr,celsius原创 2021-04-15 09:47:31 · 344 阅读 · 0 评论 -
快速排序
/*快速排序*/#include<stdio.h>int partition(int r[], int first, int end);void quicksort(int r[], int first, int end);main(){ int r[]={2,5,3,9,22,5}; int first=0, end=5; quicksort(r,0,5); for(int i=0; i<=5; i++) { prin原创 2021-04-15 09:19:09 · 91 阅读 · 0 评论