#include <stdio.h>
#include <stdlib.h>

布拉怡 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
#include <stdlib.h>

布拉怡 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
//push 東西到stack裡面
void push(int stack[],int n,int *top,int data)
{
if(*top<n-1)
{
*top=*top+1;
stack[*top]=data;
printf("stack[%d]=%d\n",*top,stack[*top]);
}
else
{
printf("full!!\n");
}
}

布拉怡 發表在 痞客邦 留言(0) 人氣()

//while binary search
#include <stdio.h>
/*binary search 使用while loop */
int binarysearch(int *list,int middle,int left,int right,int key)
{
while(left<right)
{
if(key==list[middle])
{
return middle;
}
else if(key<list[middle])
{
right=middle;
middle=(left+right)/2;
}
else
{
left=middle;
middle=(left+right)/2;
}
}

布拉怡 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
//recursive binary search
int bisearch(int key,int *list,int right,int left)
{
int middle=(left+right)/2;

布拉怡 發表在 痞客邦 留言(0) 人氣()

//recursive sequential search
#include <stdio.h>
int search(int *list,int length,int key)
{
if(length==0)
return (-1);
else if(key==list[length-1])
return(length-1);
else
return(search(list,length-1,key));

布拉怡 發表在 痞客邦 留言(0) 人氣()

//while sequentialsearch
#include <stdio.h>
int seqsearch(int n,int *list)
{
int i=0;
while(i!=10)
{
if(n==list[i])
{
return i;
}
i++;
}
return printf("False!!");

布拉怡 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
/* while loop GCD */
int GCD(int a,int b)
{
while(a%b!=0)
{
b=a%b;
}

布拉怡 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
#include <stdlib.h>
/* recursive GCD */

int GCD(int t,int v)
{
if(t%v==0)
{
return v;
}

布拉怡 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*
enter odd number
ex:5

布拉怡 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
#include <stdlib.h>
/*
題目:
m:列
n:行
d:厚度

布拉怡 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
#include <string.h> //字串要記得宣告
int parse_int(int arr)
{
int i,sum=0,remainder;
remainder=arr%10;
arr/=10;
for(i=0;i<7;i++)
{
    sum+=arr%10*(i+2);//12345678%10=8  arr=1234567
    arr/=10;                   //1234567%10=7   arr123456
}

布拉怡 發表在 痞客邦 留言(0) 人氣()

1 2
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。