码迷,mamicode.com
首页 >  
搜索关键字:for while until    ( 29426个结果
L1-071 前世档案 (20 分)
二进制水题~。 int n,m; int main() { cin>>n>>m; while(m--) { string s; cin>>s; int res=0; for(int i=0;i<s.size();i++) if(s[i] == 'n') res+=1<<(n-1-i); cout<< ...
分类:其他好文   时间:2021-04-22 15:39:34    阅读次数:0
【问题记录】pycharm控制台搜狗输入法输入中文逗号会自动变为英文逗号
#多维列表(嵌套列表) #[[姓名,年龄,工资],[姓名,年龄,工资],[姓名,年龄,工资],[姓名,年龄,工资]] #字符串:"姓名,年龄,工资"例如: "张三,30,2000" emp_list = [] while True: info = input("请输入员工信息:") if info ...
分类:其他好文   时间:2021-04-22 15:26:09    阅读次数:0
c语言实现单链表的倒叙
bool upsidedown_list(LinkList L) { Lnode *head, *tmp, *oldhead; head = L; tmp = L->next; oldhead = L; while (tmp) { oldhead->next = tmp->next; tmp->ne ...
分类:编程语言   时间:2021-04-22 15:16:52    阅读次数:0
并查集Union-find的优化问题
并查集可以有两个优化方案, 1,平衡性优化:对每个结点标记一个重量值,在进行union操作时,将重量小的添加到重量大的节点上。 2,路径压缩:在进行find操作时,顺便对路径进行压缩 private int find(int x) { while (parent[x] != x) { // 进行路径 ...
分类:其他好文   时间:2021-04-22 15:12:28    阅读次数:0
链表反转实现
方法一:双指针法 采用就地反转,不用额外开辟空间 注意:接收链表的head节点,返回当前节点 方法二:递归法 代码如下: class Node(object): def __init__(self, item, next=None): self.item = item self.next = nex ...
分类:其他好文   时间:2021-04-21 12:23:41    阅读次数:0
linux 监控服务器流量
linux 监控服务器流量 #!/bin/bash ethn=$1 while true do RX_pre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}') TX_pre=$(cat /proc/net/dev ...
分类:系统相关   时间:2021-04-21 12:03:54    阅读次数:0
CodeForces-1178F1 Short Colorful Strip 区间DP
CodeForces-1178F1 Short Colorful Strip 区间DP 题意 给定$0-n$ 一共 $n+1$种颜色,现有$m$段初始时刻颜色都是0的纸,对这张纸的段进行操作,第$i$次操作会选择第$l$段到第$r$段纸进行区间染色,条件是这段此时必须为同种颜色,染为$i$。给出最终 ...
分类:其他好文   时间:2021-04-21 11:55:16    阅读次数:0
c语言4-6 输出小于输入值的所有正偶数
输出小于输入值的所有正偶数。 1、while语句 #include <stdio.h> int main(void) { int i = 2, j; puts("please input an integer."); printf("j = "); scanf("%d", &j); while ( ...
分类:编程语言   时间:2021-04-20 15:40:50    阅读次数:0
读者-写者问题
1 typedef int semaphore; 2 semaphore count_mutex = 1; 3 semaphore data_mutex = 1; 4 int count = 0; 5 6 void reader(){ 7 while(TRUE){ 8 down(&count_mut ...
分类:其他好文   时间:2021-04-20 15:08:36    阅读次数:0
十大经典排序之堆排序(C++实现)
#堆排序 通过将无序表转化为堆,可以直接找到表中最大值或者最小值,然后将其提取出来,令剩余的记录再重建一个堆, 取出次大值或者次小值,如此反复执行就可以得到一个有序序列,此过程为堆排序。 思路: 1.创建一个堆 H[0……n-1]; 2.把堆首(最大值)和堆尾互换; 3.把堆的尺寸缩小 1,并调用 ...
分类:编程语言   时间:2021-04-20 14:08:43    阅读次数:0
29426条   上一页 1 ... 17 18 19 20 21 ... 2943 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!