#include<stdio.h> int max(int a, int b)//形参 { return a > b ? a : b; } int main() { int x, y; scanf("%d%d", &x, &y); printf("%d", max(x, y));//实际参数 ret ...
分类:
其他好文 时间:
2021-01-04 10:39:27
阅读次数:
0
获取用户输入 有时候程序需要根据用户的选择来执行不同的代码逻辑,这个时候就需要获取用户的输入了 fmt.Scan fmt.Scanln fmt.Scanf fmt.Scan 例子 import "fmt" func main() { fmt.Print("请输入用户名和年龄通过空格区别:") var ...
分类:
编程语言 时间:
2020-12-31 12:26:52
阅读次数:
0
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3065 多测 卡内存 #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<cmath> # ...
分类:
其他好文 时间:
2020-12-30 11:37:43
阅读次数:
0
1、复合语句(程序块) 例子1: 输入两个整数,计算并显示较大的值和较小的值。 #include"stdio.h" int main() { int n1,n2,max,min; puts("请输入两个整数:"); printf("整数1:"); scanf("%d",&n1); printf("整 ...
分类:
编程语言 时间:
2020-12-30 11:15:10
阅读次数:
0
//求一个整数在二进制中1的个数intmain(){intnum=0;intcount=0;scanf("%d",&num);////统计num的补码中有几个1//while(num)//{//if(num%2==1)//count++;//num=num/2;//}inti=0;for(i=0;i<32;i++){if(1==((num>>i)&1))count
分类:
其他好文 时间:
2020-12-25 12:05:35
阅读次数:
0
水题~ const int N=25; char g[N][N]; bool vis[N][N]; int n,m; PII st; bool check(int x,int y) { return x>=0 && x<n && y>=0 && y<m; } int bfs() { queue<PI ...
分类:
其他好文 时间:
2020-12-24 12:06:48
阅读次数:
0
题:https://codeforces.com/contest/1463/problem/E 题意:给定拓扑图,在给定链(以边的形式给出),问是否能在拓扑顺序中找出一个序列使得这个序列包含给定的链(x->y->z)。 分析: 给定的拓扑图我们可以当作一个DAG,然后给定的m个边我们可以在原图上进行 ...
分类:
其他好文 时间:
2020-12-24 11:46:03
阅读次数:
0
#include<stdio.h>intmain(){intn;/输入的正整数n/intstep=0;/计算步数/scanf("%d",&n);/*输入正整数n*/for(step=0;n>1;step++){if(n%2==0)/*如果n是偶数,则除以2*/n=n/2;else/*如果n是奇数,则用3n+1除以2*/n=(3*n+1)/2;}/*结束for循环*/pri
分类:
其他好文 时间:
2020-12-22 13:07:07
阅读次数:
0
#include<stdio.h>intmain(){inta=0;intb=0;intc=0;scanf("%d%d%d",&a,&b,&c);if(a<b){inttmp=a;a=b;b=tmp;}if(a<c){inttmp=a;a=c;c=tmp;}if(b<c){inttmp=b;b=c;c=tmp;}printf
分类:
其他好文 时间:
2020-12-21 11:13:40
阅读次数:
0
题目: 题目大意: 在数组中寻找和最大的一段连续的序列 思路: 用贪心的做法,从第一个开始,累加a[i],如果sum<0就把这一段给舍去掉,从新的起点开始,如果sum>max,则进行信息的更新 #include <iostream> using namespace std; const int MA ...
分类:
其他好文 时间:
2020-12-18 12:36:16
阅读次数:
2