关于在记事本写入"\n"不显示换行的原因

'\n'是 Linux上的换行 '\r\n'才是Windows上的换行 试过了,是真的。。。
Java基础 | 2017-06-20 09:30 | 阅读 3714 次 | 评论 1 条

how to solve Invalid escape sequence(valid ones are \b \t \n \f \r \” \' \\ )" syntax error

只需要把‘\’ 变成‘\\’即可
Java基础 | 2017-06-14 15:29 | 阅读 1595 次 | 评论 0 条

Java中No enclosing instance of type X is accessible报错

Java编写代码过程中遇到了一个问题,main方法中创建内部类的实例时,编译阶段出现错误,查看错误描述: Multiple markers at this line - The value of the local variable test is not used - No enclosing instance of type StaticCallDynamic is accessible. Must qualify the allocation with an enclosing instance of type StaticCallDynamic (e.g...
Java基础 | 2017-05-28 18:11 | 阅读 2433 次 | 评论 0 条

Java用户登录验证

public class passwordVerify { public static void main(String[] args) { // TODO Auto-generated method stub verify(); } public static void verify() { String originalUserName = "cs1053283896@gmail.com" ; //账号密码信息 String originalUserPassword = "123456789" ; Scanner myscanner = new...
Java基础 | 2017-05-28 13:44 | 阅读 1554 次 | 评论 0 条

Java字符串的常用方法

public static void main(String[] args) { // TODO Auto-generated method stub String aString = "hellocensi @gmail.com " ; System.out.println(aString); int lenthString=aString.length(); System.out.println("way1:"+lenthString);//常用方法1:获取字符串长度 char str[]=aString.toCharArray(); //常用方法2 :...
Java基础 | 2017-05-28 12:21 | 阅读 1737 次 | 评论 0 条

约瑟夫问题单向循环链表解决简版

#include<stdio.h> #include<stdlib.h> #define N 13 //总人数 typedef struct Node { int Data; struct Node *Next; }List,*Position; Position Create(void); Position Delete(Position Head,Position P); Position Deal(Position Head); void Traverse(Position Head); int main() //测试 { P...
c++基础 | 2017-05-27 23:12 | 阅读 1739 次 | 评论 0 条

保留n位小数的方法

public static void main(String[] args) { double sprt20=Math.sqrt(20); sprt20=(float)Math.round(sprt20*10000)/10000.0; //关键:10^n,n表示小数点后位数,且后面的10^n须带一位小数点 System.out.print(sprt20); } 结果:4.4721
Java基础 | 2017-05-23 13:12 | 阅读 1204 次 | 评论 0 条

C++实现的红黑树基本操作(English notes very cool!!)

#include<iostream> #include<cstdlib> using namespace std; #define RED 1 #define BLACK 0 typedef struct TreeNode { int Element; int Color; TreeNode *Parent; TreeNode *Left; TreeNode *Right; TreeNode() { Color=BLACK; //let initial node become black } }*MyRBTree; MyRBTree ...
c++基础 | 2017-05-09 21:41 | 阅读 1741 次 | 评论 1 条

递归实现的AVLtree的基本操作(嘿嘿,英文注释蛮爽的)

#include<iostream> #include<cstdlib> using namespace std; typedef struct TreeNode { int Element; int Height; TreeNode *Left; TreeNode *Right; }*MyAVLTree; MyAVLTree MakeEmpty(MyAVLTree &amp;T); void InorderTraverse(const MyAVLTree &amp;T); static int Max(int a,int b); static int ...
c++基础 | 2017-04-30 20:23 | 阅读 1445 次 | 评论 0 条

递归法实现二叉查找树的基本操作

#include<iostream> #include<cstdlib> using namespace std; /*查找二叉树,这里用的都是无敌的递归方法,因为它极容易理解, 也很容易编程,但值得注意的是返回值很重要*/ typedef struct TreeNode { int Element; TreeNode *Left; TreeNode *Right; }TreeNode,*MyTree; MyTree MakeEmpty(MyTree &amp;T); //二叉树置空 void InorderTraverse(const MyTree ...
c++基础 | 2017-04-29 22:36 | 阅读 1652 次 | 评论 0 条

全局有效的数据结构

一开始我用的变量是局部的它的毛病就是所有的操作只能做一次,然后啥也没改变。 那么解决的一个方法就是 引用地址 引用地址使得全局有效 不说了 直接上上点代码 typedef struct TreeNode { char Element; TreeNode *Left; TreeNode *Right; }*MyTree; void Exchange(MyTree T) { if(T) { MyTree Temp=NULL; if(T->Left||T->Right) { ...
c++基础 | 2017-04-28 16:22 | 阅读 1257 次 | 评论 0 条

数组实现的Circle队列

#include<iostream> #include<cstdlib> #define MAX 100 using namespace std; typedef struct Queue { int Array[MAX]; int Front; int Rear; } *CircleQueue; CircleQueue Create(void); //创建一个队列 int IsEmpty(CircleQueue Q); //是否为空 int IsFull(CircleQueue Q); //是否已满 void EnQueue(Circle...
c++基础 | 2017-04-27 19:19 | 阅读 1020 次 | 评论 0 条

数组实现的MyQueue顺序队列

#include<iostream> #include<cstdlib> using namespace std; typedef struct Queue { int *Array; int Front,Rear; }*MyQueue; MyQueue Create(void); //创建一个队列 int IsEmpty(MyQueue Q); //检验是否为空栈 void DeQueue(MyQueue Q); //出队 void EnQueue(int X,MyQueue Q); //入队 void GetQueueFront(MyQ...
c++基础 | 2017-04-24 18:49 | 阅读 1138 次 | 评论 0 条

链表实现的MyQueue顺序队列

#include<iostream> #include<cstdlib> #define MAXSIZE 100 using namespace std; typedef struct Node { struct Node *Next; //队列元素的节点连接 int Element; }MyNode; typedef struct Queue { Node *Front; //Front和Rear连接着各自应有的节点 Node *Rear; int Items; //队列元素的个数,用于判断是否空队列,...
c++基础 | 2017-04-23 09:44 | 阅读 1105 次 | 评论 0 条

C/C++栈的链表实现

#include<iostream> #include<cstdlib> #define LEN sizeof(struct Node) using namespace std; struct Node; typedef struct Node *PtrToNode; typedef PtrToNode Position; struct Node //节点 { int Element ; struct Node *Next; }; int IsEmpty(Position Top); //检验空栈 void GetStackTo...
c++基础 | 2017-04-22 11:03 | 阅读 1329 次 | 评论 1 条

C/C++栈的数组实现

#include<iostream> #include<cstdlib> using namespace std; int *Array=NULL; int Count=0; void Initial(int Size); //初始化栈 void Push(int Element); //入栈 int GetStackLenth(void);//获取栈的个数 void GetTopOfStack(void);//栈顶元素 void Pop(void); //出栈 void Traverse(void); //遍历 voi...
c++基础 | 2017-04-22 10:54 | 阅读 1045 次 | 评论 0 条

DoubleWayList 双向循环链表

//我发现,插入操作时,总是先把New与已有节点连接 #include<iostream> #include<cstdlib> #define LEN sizeof(struct Node) using namespace std; typedef struct Node *PtrToNode; typedef PtrToNode Position; struct Node { int Element; struct Node *Last; struct Node *Next; }; Position Create(void); ...
c++基础 | 2017-04-20 20:26 | 阅读 1241 次 | 评论 0 条

SingleCycleList单向循环链表

#include<iostream> #include<cstdlib> using namespace std; #define LEN sizeof(struct Node) #define N 6 typedef struct Node *PtrToNode; typedef PtrToNode Position; struct Node { int Element; struct Node *Next; }; Position Create(void); //创建一个循环链表 void Taverse(Position Hea...
c++基础 | 2017-04-17 12:55 | 阅读 1335 次 | 评论 0 条

SingleList单链表

#include<stdio.h> #include<stdlib.h> #include<malloc.h> struct Node; typedef struct Node *PtrToNode; //typedef PtrToNode List; typedef PtrToNode Position; struct Node { int Element; //元素 //int Subscrit; //下标 struct Node *Next; }; Position Create(void); //创建链表 void ...
C语言 | 2017-04-11 17:29 | 阅读 2650 次 | 评论 0 条

模拟drunkard的随机漫步

#include<iostream> #include<cmath> #include<cstdlib> using namespace std; const int SHIP=1; const int BAR=2; const int WATER=3; int drunkard(void) { int x=-10; //酒者一开始在酒馆 int y=0; //酒者一开始在跳板中央 int step=0; //初始化酒者的步数 while(abs(x)<=10&amp;&amp;abs(y)<=2) { switch(rand()%...
c++基础 | 2017-04-08 14:27 | 阅读 1010 次 | 评论 0 条