![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c语言/c++学习
sysu_zjl
这个作者很懒,什么都没留下…
展开
-
c++文件读写
其data0.txt的数据是这样的0,00,000,5,s0,00,001,6,s0,00,002,9,s0,00,003,7,s0,00,004,5,s0,00,005,11,s0,00,006,3,s0,00,007,3,s0,00,008,7,s0,00,009,15,s0,01,000,1,s0,01,001,3,s0,01,002,2,原创 2015-09-12 11:03:38 · 258 阅读 · 1 评论 -
【LeetCode】234. Palindrome Linked List
【LeetCode】234. Palindrome Linked List Given a singly linked list, determine if it is a palindrome. Could you do it in O(n) time and O(1) space? 判断链表回文用时间复杂度为O(n), 空间复杂度为O(1)解题思路: 由于前面刚好做过翻转链表 htt原创 2015-09-24 11:26:35 · 492 阅读 · 0 评论 -
[leetcode] #8 String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.N原创 2015-09-21 19:35:44 · 421 阅读 · 0 评论 -
[leetcode] #141 Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?用O(1)空间,判断单链表是否存在环解题思路:1、fast指针走两步, low指针走一步 2、循环后,若有环则存在fast指针追上low指针那一刻。至于为何走两步,而不走3步,4步原创 2015-10-14 10:02:29 · 459 阅读 · 0 评论 -
c语言文件读写(fread,fprintf)
利用fread进行成块的文件读写 int fread(void *buf,int size,int count,FILE *stream) int fwrite(void *buf,int size,int count,FILE *stream) fread()函数从stream 指向的流文件读取count (字段数)个字段,每个字段为size(字段长度)个字符长,并把它们放原创 2016-05-25 15:38:25 · 3275 阅读 · 0 评论 -
c++ Segmentation fault Warning
今天重新拾起c++ primer第五版复习了一下c++,看到第一章有一小处细节是之前没注意到的,特此补充。 “程序员常常在调试时添加打印语句。这类语句应该保证‘一直’刷新流。否则,如果程序崩溃,输出可能还留在缓冲区中,从而导致关于程序崩溃位置的错误推断“。 结合之前,我也经常使用过打印语句来调试代码,当出现段错误有时定位到程序错误位置,有时定位不到。才发现原来输出时是有一个与设备关联的缓冲区(b原创 2017-02-25 12:11:33 · 2428 阅读 · 0 评论 -
c++bug小结(一)
昨天打codeforces,碰到两个bug,在此总结。用一元二次方程求解公式的精度问题1、在这里用一元二次方程求解公式之后,由于数据较大极有可能造成精度不高导致转化int类型之后与实际结果差1或着差2。 如公式x*x+x-c>=0,求出满足公式的最小整数x。 这里用一元二次方程求解,由于精度的问题,导致无法得到正确结果。此时将公式转化一下 x*x+x > =c, 假设x*x+x =c, 则原创 2017-03-17 12:14:54 · 711 阅读 · 0 评论