因為phpmyadmin的管理頁面並未在var/www裡,所以要自己執行:
ln -s /usr/share/phpmyadmin /var/www/phpmyadmin
建立一個symbolic link

nanosheep 發表在 痞客邦 留言(0) 人氣()

題目如下:
有一字串陣列:a[ ]=xyz;123;abc
將其切割為
s1[ ]=xyz
s2[ ]=123

nanosheep 發表在 痞客邦 留言(0) 人氣()

#include<stdio.h>int main()
{
    void reverse(char []);
    char a[100];
    puts("Key in a word:");
    gets(a);
    reverse(a);

nanosheep 發表在 痞客邦 留言(0) 人氣()

注意!!使用遞迴實做帕斯卡三角形時,不需使用陣列。使用遞迴亦可印出三角形,不過還需增加判斷式。
而使用遞迴可直接輸入所求位置算出答案。
#include<stdio.h>int main()
{
    int i,j;
    int value(int,int);
    printf("Input i,j of a[i][j]\n");
    scanf(" %d",&i);
    scanf(" %d",&j);

nanosheep 發表在 痞客邦 留言(0) 人氣()

注意!!:我所使用的陣列是由1開始,0我不使用。因此,各位同學自行練習時,請考慮陣列起始位置與陣列大小。
#include<stdio.h>int main()
{
    int i,j,k;
    int size=15;
    printf("Input layer of Pascal Triangle:");
    scanf("%d",&size);
    int a[size+1][size+1];

nanosheep 發表在 痞客邦 留言(0) 人氣()

#include<stdio.h>
#define row 3
#define col 3
int main()
{
    int a[row][col]={1,2,3,
                               4,5,6,
                               7,8,9};
    int b[row][col]={9,8,7,
                               6,5,4,
                               3,2,1};
    int c[row][col]={0,0,0,
                              0,0,0,
                              0,0,0};
    int i,j,k;    for(i=0;i<row;i++)
    {
        for(j=0;j<row;j++)
        {
            for(k=0;k<col;k++)
            {
                c[i][j]=c[i][j] + a[i][k]*b[k][j];
            }
        }
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
            printf("%d ",c[i][j]);
        printf("\n");
    }
}

nanosheep 發表在 痞客邦 留言(0) 人氣()

Q8_16:
#include<stdio.h>int main()
{
    int find_k(int);
    int n;
    printf("Input N:");
    scanf("%d",&n);
    printf("K is %d.\n",find_k(n));   //將n的值傳入find_k(),其回傳值為k
    return 0;
}

nanosheep 發表在 痞客邦 留言(0) 人氣()

Q3a:
#include<stdio.h>int main()
{
    int i,now=1,last=1,temp=0,sum=0,n;
    printf("Input a number:");
    scanf("%d",&n);
    printf("Fib(1)=1\n");
    for(i=2 ; i<=n; i++)
    {
        temp=now;
        now=now+last;  //now is equal temp,so it can write on now=temp+last
        last=temp;
        printf("Fib(%d)=%d\n",i,now);
        sum = sum + now;
    }
    printf("Sum=%d\n",sum);
    return 0;
}
Q3b:

nanosheep 發表在 痞客邦 留言(0) 人氣()

Q2a:
#include<stdio.h>int main()
{
    int i,j,flag;
    for(i=1;i<=1000;i++)
    {
        flag=0;
        for(j=2;j<i;j++)
        {
                if(i%j==0)
                {
                        flag=1;
                }
        }
        if(flag==0)
        {
                printf("%d is a prime.\n",i);
        }
   }
    return 0;
}
Q2b:

nanosheep 發表在 痞客邦 留言(0) 人氣()

#include<stdio.h>int main()
{
 int n,i,sum=0;
 printf("Input a number:");
 scanf("%d",&n);
 for(i=1;i<n;i++)
 {
     if(n%i==0)
     {
        sum=sum+i;
     }
 }
 printf("The sum of %d's factors is %d\n",n,sum);
 return 0;
}

nanosheep 發表在 痞客邦 留言(0) 人氣()

#include <stdio.h>
#include <stdlib.h>int main(void){
  double Euler(int n);
  int find_k(int n);
  int is_prime(int n);

nanosheep 發表在 痞客邦 留言(3) 人氣()

A:
輸出結果:
my_fun(5)=1.716667
my_fin(8)=1.718279
my_fun(10)=1.718282

nanosheep 發表在 痞客邦 留言(1) 人氣()

1 2
Blog Stats
⚠️

成人內容提醒

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

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