This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*input :A[n] | |
| * output:k-th large number | |
| */ | |
| #include <stdio.h> | |
| #include <time.h> | |
| #include <stdlib.h> | |
| #define LEN(a) (int)(sizeof(a)/sizeof(a[0])) | |
| #define SWAP(a,b) do{int temp;temp=a;a=b;b=temp;}while(0) | |
| int searchk(int a[],int left,int right,int k); | |
| void print(int a[],int start,int end); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| #include <stdio.h> | |
| #define FILEPATH "/Users/tinylamb/Documents/coding/santi.txt" | |
| int main(){ | |
| FILE *fp; | |
| fp=fopen(FILEPATH,"r"); | |
| char c; | |
| while((c=fgetc(fp))!=EOF) | |
| printf("%c",c); | |
| fclose(fp); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #encoding:utf-8 | |
| from Tkinter import * | |
| import urllib2 | |
| from lxml import html | |
| import os,sys | |
| class App: | |
| def __init__(self,master): | |
| self.label=Label(master,text='输入日记首页地址:') | |
| self.label.pack(side='left',padx=5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*Exercise 6-1. Our version of getword does not | |
| * properly handle underscores, string constants, | |
| * comments, or preprocessor control lines. Write a better version. | |
| */ | |
| #include <stdio.h> | |
| #include <ctype.h> | |
| #define LIMIT 20 | |
| #define STRCONSTANT 0 | |
| #define COMMENT 1 | |
| #define WORD 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| quick sort v1 | |
| http://zh.wikipedia.org/wiki/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F | |
| */ | |
| #include<stdio.h> | |
| void qsort(int a[],int left,int right); | |
| int findp(int v[],int left,int right);//find pivot position | |
| void swap(int *,int *); | |
| int main(){ | |
| int a[]={5,4,3,1,4,5,6,8,9,0}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Exercise 5-1. As written, getint treats a + or - not followed | |
| by a digit as a valid representation of zero. | |
| Fix it to push such a character back on the input. | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <ctype.h> | |
| #define MAXSIZE 100 | |
| int getch(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define ElemType int | |
| #define MAXSIZE 100 | |
| /*...ADT stack...*/ | |
| /*数据集定义*/ | |
| typedef struct Stack{ | |
| int stacksize; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*reference http://users.powernet.co.uk/eton/kandr2/index.html*/ | |
| /* | |
| Exercise 4-1. Write the function strindex(s,t) which returns the position of | |
| the first occurrence of t in s, or -1 if there is none. | |
| */ | |
| #include <stdio.h> | |
| #define SIZE 100 | |
| int strindex(char s[] , char p[]);//return (p in s)?index:-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*reference http://users.powernet.co.uk/eton/kandr2/index.html*/ | |
| /* | |
| Exercise 3-1. Our binary search makes two tests inside the loop, when one would suffice (at the price of | |
| more tests outside.) Write a version with only one test inside the loop and measure the difference in runtime. | |
| */ | |
| #include <stdio.h> | |
| int binarysearch(int a[],int x,int n){ | |
| int low=0,high=n-1; | |
| int mid=(low+high)/2; | |
| while(low<=high && a[mid]!=x){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*reference http://users.powernet.co.uk/eton/kandr2/index.html*/ | |
| /* | |
| Exercise 2-1. Write a program to determine the ranges of char, short, int, and long variables, both | |
| signed and unsigned, by printing appropriate values from standard headers and by direct | |
| computation. Harder if you compute them: determine the ranges of the various floating-point types. | |
| */ | |
| /*********too slow*************** | |
| #include <stdio.h> | |
| #define ElemType signed short | |
| int main(){ |