line

C# (sharp) reading random line from txt file [duplicate]

[亡魂溺海] 提交于 2019-12-06 13:20:24
This question already has answers here : Read random line from a file? c# (2 answers) Closed 6 years ago . Can anyone tell me how to read random line from txt file? I want to read random line from txt file and show only that line in textBox. Code examples would be great! Thanx in foward var lines = File.ReadAllLines(path); var r = new Random(); var randomLineNumber = r.Next(0, lines.Length - 1); var line = lines[randomLineNumber]; The simplest solution is to read all the lines to memory and pick one randomly. Assuming that all the lines can fit in memory. string[] allLines = File.ReadAllLines

动态分区最佳-最坏-最先分配

眉间皱痕 提交于 2019-12-06 11:39:33
#include<iostream> #include<cstring> #include<string> #include<queue> #include<algorithm> using namespace std; int maxsize; int k[50]; typedef struct memory { bool flage; string name; int start; int size; memory *front; memory *next; }rd; rd *line = new rd; /* struct node { string name; string operate; int size; }node1,node2; */ void init() { line->flage = 0; line->name = "空"; line->start = 0; line->size = maxsize; line->front = NULL; line->next = NULL; } void display() { rd *di = new rd; di = line; while (di != NULL) { cout << di->flage << " " << di->name << " " << di->start << " " << di-

Subset Data for ggplot2 graph

淺唱寂寞╮ 提交于 2019-12-06 11:00:59
I am working with ggplot2 and have a question about how to subset data for plots. I have the following dataset (example) and need to create a line plot comparing Q1 data by year of Company A. x= 2015 Q1, 2016 Q1, 2017 Q1 y= Data for Company A Company Year Quarter Data A 2015 Q1 1 B 2015 Q1 2 C 2015 Q1 3 A 2015 Q2 4 B 2015 Q2 5 C 2015 Q2 6 A 2015 Q3 7 B 2015 Q3 8 C 2015 Q3 9 A 2016 Q1 10 B 2016 Q1 11 C 2016 Q1 12 A 2016 Q2 13 B 2016 Q2 14 C 2016 Q2 15 A 2016 Q3 17 B 2016 Q3 18 C 2016 Q3 19 For other graphs involved in this project I've been using this code: ggplot(df[df$Company=="A",], aes(x= ,

Match if previous line starts with character

十年热恋 提交于 2019-12-06 10:10:54
问题 I have a file, that looks like this: expression1 - expresson1.1 - expressoion1.2 expression2 -expression2.1 expression3 -expression3.1 -expression3.2 -expression3.3 What I want to do is, delete lines 1.2, 3.2 and 3.3, so only lines that do not start with a minus, and the next line remain. So I tried writing a regex that matches every line starting with a minus where the previous one also started with a minus, and then delete them. So far, no success. Any hints would be very appreciated. 回答1:

Go 关系运算符

冷暖自知 提交于 2019-12-06 09:57:06
Go 关系运算符 package main import "fmt" func main() { var a int = 21 var b int = 10 if( a == b ) { fmt.Printf("Line 1 - a is equal to b\n" ) } else { fmt.Printf("Line 1 - a is not equal to b\n" ) } if ( a < b ) { fmt.Printf("Line 2 - a is less than b\n" ) } else { fmt.Printf("Line 2 - a is not less than b\n" ) } if ( a > b ) { fmt.Printf("Line 3 - a is greater than b\n" ) } else { fmt.Printf("Line 3 - a is not greater than b\n" ) } /* Lets change value of a and b */ a = 5 b = 20 if ( a <= b ) { fmt.Printf("Line 4 - a is either less than or equal to b\n" ) } if ( b >= a ) { fmt.Printf("Line 5 - b is

Go 逻辑运算符

社会主义新天地 提交于 2019-12-06 09:56:51
Go 逻辑运算符 package main import "fmt" func main() { var a bool = true var b bool = false if ( a && b ) { fmt.Printf("Line 1 - Condition is true\n" ) } if ( a || b ) { fmt.Printf("Line 2 - Condition is true\n" ) } /* lets change the value of a and b */ a = false b = true if ( a && b ) { fmt.Printf("Line 3 - Condition is true\n" ) } else { fmt.Printf("Line 3 - Condition is not true\n" ) } if ( !(a && b) ) { fmt.Printf("Line 4 - Condition is true\n" ) } } 本文转自: http://codingdict.com/article/23570 来源: https://www.cnblogs.com/bczd/p/11975517.html

C# 读取和写入txt文件

巧了我就是萌 提交于 2019-12-06 09:55:24
读取: 1.使用StreamReader读取文件,然后一行一行的输出   StreamReader sr = new StreamReader(path,Encoding.Default);   String line;   while ((line = sr.ReadLine()) != null)   {     Console.WriteLine(line.ToString());   } 写入: 1. File.WriteAllText(filePath, str, Encoding.UTF8); //filePath:txt文件地址。str:写入的字符串变量。注:如果文件已经存在则覆盖,不会报错。 来源: https://www.cnblogs.com/maycpou/p/11975427.html

svg: How to set a circle on the calculated line?

﹥>﹥吖頭↗ 提交于 2019-12-06 08:57:56
问题 I'm trying to set a circle on the calculated line with svg. Here is my the example: http://jsfiddle.net/7XC9j/ html: <svg width="300" height="500"> <g id="g-1"></g> </svg> javascript: var line = d3.svg.line() .x(function(d) { return d.x; }) .y(function(d) { return d.y; }) .interpolate("cardinal") .tension(0); var points = [{x: 0, y: 200}, {x: 25, y: 180}, {x: 50, y: 150}, {x: 100, y: 145}, {x: 200, y: 130}, {x: 300, y: 120}, {x: 500, y: 25}]; d3.select("#g-1").append("path").attr("d", line

Matlab: Changing line specifications

自古美人都是妖i 提交于 2019-12-06 08:14:49
I would like to automatically create graphs of Hardness H and Young's modulus E of samples as function of load L of indenter. My goal is to get opaque markers connected with dashed lines. When using set(handle,'linestyle',spec) or line(...,'linestyle',spec) command I got markers or lines, never both of them - MATLAB throws error. Is there way to get lines and markers without plotting two lines with same data and different specs? I'd like to continue with this to work with legend as described in another question ( MATLAB: legend for plotyy with multiple data sets ). Here is my actual MWE code:

QDBus与gdbus的数据传递详解

a 夏天 提交于 2019-12-06 08:10:05
在Linux平台的进程间通信多了一个dbus技术,应用还是非常广的,其中有一个应用模式是采用gdbus实现相关业务逻辑,采用QtService调用qdbus暴露出服务给客户使用。这种模式还是非常便捷的。不过QDBus和gdbus相关资料还请自行查找。这里只是针对他们的数据传递(函数的参数)进行详解。 1,框架的建立 首先我们需要根据业务需要建议一个xml文件hello.xml,描述interface以及包含的函数等信息,比如: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="introspect.xsl"?> <node xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="/org/alibaba/kenton" xsi:noNamespaceSchemaLocation="introspect.xsd"> <interface name="org.alibaba.kenton.hello"> <version>1.0.0</version> <doc> <line>This is a test interface</line> </doc> <method name="GetVersion"> <doc>