lf

浅谈CR,LF和CRLF

二次信任 提交于 2020-01-16 03:17:12
以Pycharm为例: 点击CRLF,有三个可供选择: 其实注释得很明白: CR用于Mac下,作用相当于 \r LF用于Unix下,作用相当于 \n CRTF用于Windows下,作用相当于 \r\n 简单介绍下三者: CR:Carriage Return LF: Line Feed CRTF:Carriage Return Line Feed 其实这个根源于打印机时代,现代键盘由以前的打印机键盘演变而来,在打印机时代换行是通过xxxxxx 而这个传统延申到了现代,在Mac下,文本的换行体现在代码(ASCII)层面是\r,Unix下是\n,Windows下是\r\n。在协同工作时就可能出现问题,如三个人使用三个平台通过Git修改一份文件,如果不经过任何处理,则三个人每次提交的文件都和之前的文件冲突(假设最近一次修改不是自己)—— 换行符不一样。 为了解决这个问题,IDE提供了这样一个跨操作系统的自定义模式:自己设置换行方式。 回到之前的问题,现在三个人都约定好:我们将IDE的换行方式都设置为CRLF进行开发,这样提交git就不会冲突了。 但是,在实际开发中,这其实是不实用的,在终端跨平台去约定每个人的开发习惯不安全也不方便。所幸Git本身提供这样的功能:设置autocrlf属性,具体设置详见 关于CRLF的一些坑 ,一般而言,这个属性有三个值: true

R equivalent for .NET's Environment.NewLine

偶尔善良 提交于 2020-01-15 03:42:23
问题 Is there an R equivalent for Environment.NewLine in .NET? I'm looking for a character object that would represent a new line based on the environment, e.g. CR LF ("\r\n") on Windows and LF ("\n") on Unix. I couldn't find any such thing in the R documentation, or the default R options. 回答1: There’s no equivalent, but most of the time you won’t need it: as long as you’re writing to a text connection, the operating system will do the correct thing and treat '\n' according to the platform’s

42_一元二次方程

强颜欢笑 提交于 2020-01-10 04:12:50
解一元二次方程ax2+bx+c=0的解。题目保证有两个不同的解。 Input: a,b,c的值。 Output: 两个根X1和X2,其中X1>=X2。。 结果保留两位小数。 Sample Input: 1 5 -2 Sample Output: 0.37 -5.37 **************************************************************************** #include<stdio.h> #include<math.h> int main() { double a,b,c; scanf("%lf %lf %lf",&a,&b,&c); double x1 =( (-b) + sqrt(b * b - 4 * a * c) ) / ( 2 * a ); double x2 =( (-b) - sqrt(b * b - 4 * a * c) ) / ( 2 * a ); printf("%.2lf %.2lf",x1,x2); return 0; } *************************************************************************** 来源: CSDN 作者: 徐文小涛涛 链接: https://blog.csdn.net/qq_41440031

C 求三角形面积 SDUT

你离开我真会死。 提交于 2020-01-09 23:36:41
Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 已知三角形的边长a、b和c,求其面积。 Input 输入三边a、b、c。 Output 输出面积,保留3位小数。 Sample Input 1 2 2.5 Sample Output 0.950 Hint 海伦公式求三角形面积。如果三角形的三边为a, b, c且p=(a+b+c)/2,则三角形面积为(p*(p-a) * (p - b) * (p -c))的平方根。 Source # include <stdio.h> # include <stdlib.h> # include <math.h> double f ( double a , double b , double c ) { double p , area ; p = ( a + b + c ) / 2.0 ; area = sqrt ( ( p * ( p - a ) * ( p - b ) * ( p - c ) ) ) ; return area ; } int main ( ) { double a , b , c ; scanf ( "%lf%lf%lf" , & a , & b , & c ) ; printf ( "%.3lf\n" , f ( a , b , c ) ) ;

Git中CRLF与LF的转换

元气小坏坏 提交于 2020-01-03 03:22:00
1.换行符在不同的操作系统上的表示 首先要理解的一点是,对于不同的操作系统,对于换行符的表示是不一样的。也就是说当我们在编辑一个文件,在键盘上按下回车键的时候,对于不同的操作系统保存到文件中的换行符是不一样的。见下表: CR : 表示回车\r LF : 表示换行\n CRLF : 表示回车换行\r\n 敲下回车键,不同的操作系统保存到文件中的值: Windows:使用的是CRLF == > 即\r\n,文件中保存的是\r\n Linux / Unix : 使用的是LF == > 即\n,文件中保存的是\n Mac OS : 使用的是CR == > 即\r,文件中保存的是\r Mac OS X系统:使用的是LF == > 即\n,文件中保存的是\n(Mac OS X已经改成和Unix / Linx一样使用LF) 问题: 既然不同的操作系统,对于换行符使用不同的表示形式,如果一个团队在开发一个共同的项目,如果你使用的是windows系统,而你的小伙伴用的是Mac的话,当你们使用git协同开发软件时,就会出现换行符不统一的问题。 虽然对于不同的操作系统,默认的换行符的表示方法不一样,但是编辑器是可以设置在敲下回车键的时候保存的换行符是什么的,比如常用的vscode就可以进行设置。直接点击编辑器右下角的LF或者CRLF,出现如下图所示的设置,直接选择即可。在设置完成之后,在敲回车键

Jekyll LF/CRLF issue with git

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 05:01:52
问题 I have a Jekyll folder in which only the production part ( _site ) is tracked with git. When I run the command to serve the local site with jekyll serve -w , the files will be changed to LF or CRLF depending on the machine I'm working on: CRLF for Windows, LF for Mac. This is really annoying because all my files inside _site will be commited everytime I switch my OS. I've tried to fix this in the git config file with autocrlf = false , but since the files are generated at a higher level by

swing substance look&feel download

﹥>﹥吖頭↗ 提交于 2019-12-22 04:09:51
问题 Where do I download Substance L&F for Swing? 回答1: The incredibly sloppy java.net transition has discarded the old download links, they're gone gone gone. Kirill's solution is simply to post the code to GitHub. See his blog post about it. As a consequence, I have forked the distro to do maintenance and upkeep. Read my blog post about it. 回答2: May be at substance.dev.java.net Also here you will find source code for all and can also download them all. Also see here. 回答3: You can Insubstantial

[git] warning: LF will be replaced by CRLF | fatal

浪子不回头ぞ 提交于 2019-12-20 22:38:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 遇到这两个错误, 基本上都是叫你将 autocrlf 设置为 false. 但是我觉得这样很不妥。 如果你的源文件中是换行符是LF,而autocrlf=true, 此时git add就会遇到 fatal: LF would be replaced by CRLF 的错误。有两个解决办法: 1. 将你的源文件中的LF转为CRLF即可【推荐】 2. 将autocrlf 设置为 false 如果你的源文件中是换行符是CRLF,而autocrlf=input, 此时git add也会遇到 fatal: CRLF would be replaced by LF 的错误。有两个解决办法: 1. 将你源文件中的CRLF转为LF【推荐】 2. 将autocrlf 设置为true 或者 false 我的建议:在Mac上设置 autocrlf = input, 在Windows上设置autocrlf = true(默认值)。 ---------------------------------------------------------------------------------------------------------------------------------- 这样的话, Windows:(true) 提交时

git and CR vs LF (but NOT CRLF)

拜拜、爱过 提交于 2019-12-20 10:45:01
问题 This may sound like a redundant question (and may very well be a redundnant question) but I can't find the answer. Here's the situation: My application is creating text files that have CR's as line endings. More specifically I'm not explicitly setting the line endings to CR, it just happens to be the output of the command I'm using to get the text body. Of course I could manually convert the CR's to LF's but I don't want to if I can avoid it. Git's treating these files as a single line (e.g.

git windows下换行符问题 LF与CRLF转换

我只是一个虾纸丫 提交于 2019-12-19 07:08:37
解决 1 GIT 设置 git config -- global core . autocrlf false git config -- global core . safecrlf true AutoCRLF #提交时转换为LF,检出时转换为CRLF git config -- global core . autocrlf true #提交时转换为LF,检出时不转换 git config -- global core . autocrlf input #提交检出均不转换 git config -- global core . autocrlf false SafeCRLF #拒绝提交包含混合换行符的文件 git config -- global core . safecrlf true #允许提交包含混合换行符的文件 git config -- global core . safecrlf false #提交包含混合换行符的文件时给出警告 git config -- global core . safecrlf warn 2.IDE设置使用UNIX换行符 File -> Settings Editor -> Code Style Line separator (for new lines) ,选择:Unix and OS X (\n) 对已使用Windows换行符的文件