摘要: #include <stdio.h>#include <string.h>int findStart(int start,char str[],char pat[]);int match(int start,char str[],char pat[]);int main(){ char str[100]="abljfvbajlfvblaksdbc;laksdbnc;afgvblaiusgdvlciuaosdgbcui;la"; char pattern[]="aks"; //printf("%d",findSt 阅读全文
posted @ 2013-03-26 16:15 cart55free99 阅读(165) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>void clrArr(char arr[]);int main(){ char ch; char maxLine[200];//用于装载最长的一行 //假设最长行字符数不超过200 int max=0;//记录已发现的最长字符个数 int i=0;//记录每行的字符数 char line[200]; char* filename="D:/23.txt"; FILE *fp; if((fp=fopen(filename,... 阅读全文
posted @ 2013-03-26 15:27 cart55free99 阅读(271) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int isLetter(char ch);int main(){ int countWords=0; int countLines=0; char ch; char chPre; while( (ch=getchar())!=EOF ){//EOF是一个字符型常量 if(ch=='\n'){ countLines++; } if(isLetter(chPre)&& (ch==' '||ch=='\0' || ch=='\n' || ch=='.' ) 阅读全文
posted @ 2013-03-26 14:46 cart55free99 阅读(304) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <math.h>double f(double x);double f2(double x);int main(){ //利用迭代法求√a的值 int a=7; double s1=0; double s2=0; s2=a; while( fabs(s1-s2)>1e-5 ){//10^-5 s1=s2;//进行新的一轮计算 //原来的后一项是现在的第一项 s2=(s1+a/s1)/2; } printf("%lf",s2); //利用牛... 阅读全文
posted @ 2013-03-26 13:48 cart55free99 阅读(423) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <math.h>void clearYinziArr(int arr[]);int aItem(int key, int i);int main() { //求PI //pi=4*(1-1/3+1/5-1/7+1/9-1/11....) //本次求PI 直到某一项绝对值小于 10^(-6) int sign = 1;//控制正 负 double fenmu = 1; double sum = 0; while (fabs(1 / fenmu) > 1e-6) { //fabs是math.h中的函数... 阅读全文
posted @ 2013-03-25 22:33 cart55free99 阅读(302) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#define N 30int out(int str[], int start, int counts);int main() { int str[30]; int i = 0; for (; i < 30; i++) { str[i] = i + 1; } // printf("%d,\n", out(str, 0, 9));//10 //ok int rest = 30; int start = 0; while (rest > 15) { start = out(str... 阅读全文
posted @ 2013-03-25 20:30 cart55free99 阅读(163) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>void myCount(char *filename);void maxLine(char *filename);int main(){ char *filename="D:/23.txt"; myCount(filename); maxLine(filename); return 1;}void myCount(char * filename){ FILE * fp; fp=fopen(filename,"r&qu 阅读全文
posted @ 2013-03-25 16:51 cart55free99 阅读(181) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int binSearch(int arr[], int low, int high, int key);int binSearch2(int arr[], int low, int high, int key);int binSearch3(int arr[],int start,int ends,int key);int main() { int arr[]={3,8,11,15,17,22,23,26,28,29,34}; //printf("%d",binSearch(arr,0,10,26)); printf(&qu 阅读全文
posted @ 2013-03-25 11:18 cart55free99 阅读(153) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#define N 4int maxInL(int arr[4][4], int line);int minInC(int arr[4][4], int col);int main() { // int arr[4][4]={ // {15,23,34,18}, // {19,20,16,9}, // {14,7,6,5}, // {10,4,3,1} // }; int arr[4][4] = { { 67, 68... 阅读全文
posted @ 2013-03-25 10:28 cart55free99 阅读(184) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>typedef struct Node { int data; struct Node *next;} Node;void getInfo(Node * node);int printNodes(Node *node);void saveToFile(Node * node, char * filename);void readFromFile(char * filename, int n);Node nodes[20];int main() { Node *first = (Node *) ma 阅读全文
posted @ 2013-03-24 22:13 cart55free99 阅读(438) 评论(0) 推荐(0) 编辑