00编写一个程序,接受用户的输入并保存为新的文件:def file_write(file_name): f = open(file_name, 'w') print('请输入内容【单独输入\':w\'保存退出】:') while True: write_some ...
分类:
其他好文 时间:
2014-07-08 22:10:19
阅读次数:
353
def Merge(head1, head2):
if head1 == None: return head2
if head2 == None: return head1
psuhead = ListNode(-1)
tail = psuhead
while head1 and head2:
if head1.val < head2.val:
cur = head1
...
分类:
其他好文 时间:
2014-07-08 18:46:04
阅读次数:
227
代码块的重定向是指在代码块内将标准输入或标准输出重定向到文件,而在代码块外还是保留默认状态,换句话说,代码块重定向指对标准输入或者标准输出的重定向只在代码块内有效。可以重定向的代码块是while、until、for,也可以是if/then,甚至是函数。
while重定向
#!/bin/bash
ls /etc> logs
while [ "$filename" != "rc.d" ...
分类:
系统相关 时间:
2014-07-08 18:42:10
阅读次数:
278
1.先序遍历非递归算法
#define maxsize 100
typedef struct {
Bitree Elem[maxsize];
int top;
} SqStack;
void PreOrderUnrec(Bitree t) {
SqStack s;
StackInit(s);
p=t;
while (p!=...
分类:
其他好文 时间:
2014-07-08 17:13:18
阅读次数:
267
def reverse(head):
if head == None or head.next == None:
return head
psuhead = ListNode(-1)
while head:
nexthead = head.next
head.next = psuhead.next
psuhead.next = head
head = nexthead
...
分类:
其他好文 时间:
2014-07-08 15:27:58
阅读次数:
183
如何快速学习ruby ?
学习语言最快的思路。
变量,常量,变量类型,操作符,
逻辑语句如 if, else, switch, for, foreach, do while, break, 等等。要学的语言与这些命令相似的命令是什么?了解使用方法即可。
之后,如果是面向对象,就要了解一下关于对象的操作了。
有没有函数库,一般语言都有的。输出命令函数,操作数组,操作字符串,对象属性
操作...
分类:
其他好文 时间:
2014-07-08 14:35:27
阅读次数:
143
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace C_编辑基础
{
//枚举的意义就是限定变量的取值范围
enum gender{Male,Female,Unkown}; //声明一个类型,它是枚举类型(定义一个枚举),这个枚举有三个值。...
分类:
其他好文 时间:
2014-07-08 13:38:36
阅读次数:
191
def isOdd(n):
return n & 1
def Reorder(data, cf = isOdd):
odd = 0
even = len( data ) - 1
while True:
while not isOdd( data[ even ]) : even -= 1
while isOdd( data[ odd ]) : odd += 1
if odd ...
分类:
其他好文 时间:
2014-07-08 12:47:26
阅读次数:
276
题目:构造n位01串,其中有m个1的所有组合。
分析:搜索、枚举。可以利用库函数,求解,也可以利用dfs求解;我这里采用位运算计算组合数。
说明:注意库啊!
#include
#include
#include
using namespace std;
int S[20];
int main()
{
int T,N,M;
while ( cin >> T )
for ( i...
分类:
其他好文 时间:
2014-07-08 11:24:33
阅读次数:
199
#include<iostream>
usingnamespacestd;
structnode{
intd;
structnode*next;
};//定义结点
node*build1()//头插法构造单链表
{
node*p;//指向新建结点
node*head;//头指针
head=NULL;
p=head;
intx;
cin>>x;
while(x!=-1)
{
p=newnode;
p->d=x;
p-&g..
分类:
其他好文 时间:
2014-07-08 09:06:06
阅读次数:
220