- 博客(30)
- 资源 (1)
- 收藏
- 关注
翻译 求解逆矩阵
#include <stdio.h>#include <stdlib.h>#define true 1#define false 0double** expand_matrix;double** new_matrix;void initExpandMatrix(double ** mat, double ** expand_mat, int);int adjustMatrix(double ** expand_mat, int len);void calcula
2023-02-18 19:15:48 73
翻译 一个已排序数组插入一个数,扔保持有序输出
#include<stdio.h>int main(){ int a[11]={1,4,6,9,13,16,19,28,40,100}; int temp1,temp2,number,end,i,j; printf("array a:\n"); for(i=0;i<10;i++) printf("%5d",a[i]); printf("\n"); printf("insert data:"); scanf("%d",
2023-02-18 19:12:04 84
翻译 利用指向指针的指针方法给整数排序
#include <stdio.h>void sort(int **p,int n){ int i,j,*temp; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(**(p+i)>**(p+j)){ //比较后交换整数地址 temp=*(p+i); *(p+i)=*(p+j); *(p+
2023-02-18 19:11:24 125
翻译 利用冒泡排序按顺序排列10个字符大小
#include <stdio.h>#include <string.h>#define N 10char str[N];void sort(char str[]){ int i,j; char t; for(j=1;j<N;j++) for(i=0;(i<N-j)&&(str[i]!='\0');i++) if(str[i]>str[i+1]){
2023-02-18 19:06:07 217
翻译 纸张尺寸.
#include<stdio.h>main(){ int i,x=1189,y=841; char a[4]={0}; scanf("%s",a); //len用来存放要裁剪多少次的数 int len =a[1]-'0';//取A1,A2的那个数字看看是A几的纸; for(i=0;i<len;i++){ //转换边和长 int t=x; x=y; y=t;
2023-02-12 10:57:23 57
翻译 斐波那契数列
//递归 #include<stdio.h> int Fib(int n) { if(n==1||n==2)//数列前两项 { return 1; } else//从第三项开始 { return Fib(n - 1) + Fib(n - 2); } return 0; } int main() {
2023-02-12 10:55:35 35
翻译 全素日..
#include <stdio.h>#include <stdbool.h>#include <string.h>bool is_prime(int num){ if(0==num || 1==num) return false; for(int i=2;i<num;i++) { if(0==num%i) return false; } return true;}int main(i
2023-02-12 10:52:12 45
翻译 正整数金字塔
#include <stdio.h>#include <stdlib.h>typedef struct _WORDS{ int num; int level; int idx; _WORDS *next;}WORDS;WORDS *head = NULL;int n=0;void createWords(){ head = (WORDS*)malloc(sizeof(WORDS)); head->num
2023-02-09 09:14:14 33
翻译 最大上升字串
#include <stdio.h>#include <stdlib.h>#define MAXSIZE 12typedef struct subIdx { int begin; int end;} SUB_IDX;typedef struct maxSub { SUB_IDX subPosition; int num;} MAX_SUB;MAX_SUB * MaxSubScan(const int* array, int len)
2023-02-09 09:10:01 98
翻译 和最大字串
#include <stdio.h>#include <stdlib.h>#define MAXSIZE 11typedef struct subIdx { int begin; int end;} SUB_IDX;typedef struct maxSub { SUB_IDX subPosition; int sum;} MAX_SUB;MAX_SUB * MaxSubScan(const int* array, int
2023-02-09 09:08:59 48
翻译 随机快速排序问题
#include <stdio.h>#include <stdlib.h>#define MAXSIZE 10//p,r为边界,先处理左边再处理右边void QuickSort(int a[],int p,int r){ if(p<r) { int q = Partition(a,p,r); QuickSort(a,p,q-1); QuickSort(a,q+1,r); }}void Sw
2023-02-06 14:27:42 42
翻译 棋盘覆盖问题.
#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAXSIZE 8int Board[MAXSIZE][MAXSIZE];int title=1;//全局序号//tr:棋盘左上角方格的行号//tc:棋盘左上角方格的列号//dr:特殊方格所在的行号//dc:特殊方格所在的列号//size:size=2^k 棋盘规格为2^k*2^kvoid Che
2023-02-06 14:26:25 51
翻译 旅行商问题
#include <stdio.h>#include <stdlib.h>#define MAXSIZE 10#define FINITY 1000int thingnum; //节点数int bian;//边个数int a[MAXSIZE][MAXSIZE];//邻接矩阵int x[MAXSIZE]={0,3,2,5,1,4};int cc=0;int bestc=FINITY;int bestx[MAXSIZE];//输出邻接矩阵void o
2023-02-04 17:47:22 167
翻译 最长公共子序列
#include <stdio.h>#include <stdlib.h>#define MAXSIZE 10int c[MAXSIZE][MAXSIZE];int flag[MAXSIZE][MAXSIZE];int a[MAXSIZE] = {1,2,3,2,4,1,2,5};int b[MAXSIZE] = {2,4,3,1,2,1,5};//递归找最长公共子序列长度int find_longest(int asize,int bsize){ int
2023-02-04 17:45:57 32
翻译 全排列问题
#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAXSIZE 7void swap(int a[],int left,int right){ int tmp; tmp = a[left]; a[left] = a[right]; a[right] = tmp;}//全排列void pailie(int a[],int left,in
2023-02-02 21:19:43 37
翻译 整数划分.
#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAXSIZE 5int mark[200];int q2(int n,int m){ if(n==1|| m==1) return 1; if(m==n) { return 1+q2(n,n-1); } if(m>n) return q2(n,n); if(m&l
2023-02-01 18:25:52 148
翻译 最小生成树.
#include <stdio.h>#include <stdlib.h>#define MAXSIZE 10typedef struct{ char letter; int id;} letter_struct;typedef struct{ letter_struct one; letter_struct two; int num;} edge;edge a[MAXSIZE]= {{{'d',4},{'e
2023-01-30 21:29:56 37
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人