目前分類:課業*School Work (148)

瀏覽方式: 標題列表 簡短摘要
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:我肚子好痛‧心好痛‧頭好痛‧腰好痛
  • 請輸入密碼:
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:today
  • 請輸入密碼:
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:自己寫50%‧位億教50%
  • 請輸入密碼:
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:我很難過
  • 請輸入密碼:
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:心情很
  • 請輸入密碼:
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:寫到很
  • 請輸入密碼:
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:資科
  • 請輸入密碼:
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:寫的很......
  • 請輸入密碼:

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

main ()
{
    FILE *fp; //指標 變數名
    int i,j,newline;   
    struct Line{int Lnumx,Lnumy,stx,sty,enx,eny;//線段名稱 <x,y>
                char attribute;//存明筆或暗筆 V H
                };
    //第X劃的第Y線段 設一個Line結構 來存兩個點的值
    struct Word{
           char s[5];//存注音符號 
           int count;//存最多可以幾條線
           struct Line Lines[10];//用法:結構名+變數名[個數]
           }; //設Char的結構來存注音符號、線的數量以及引進Line的格式(兩個點)
           //來構成Char
    struct Word All[37];//宣告37個
       
    fp=fopen("D:/94413016/20070329/a.txt","r");//開檔
           if(fp==NULL){//檢查開檔有沒有成功
                        printf("open file error\n");
                       }
/*讀檔*/   
    for (i=0;i<37;i++) //因為已知txt檔的內容所以才可以這樣寫
    {
     fscanf(fp,"%s %d",All[i].s,&All[i].count);//將 count 讀入(位置)
     for(j=0;j<All[i].count;j++)
        {      
           fscanf(fp,"%d%d%d%d",&All[i].Lines[j].stx,&All[i].Lines[j].sty,
           &All[i].Lines[j].enx,&All[i].Lines[j].eny);//印出線的兩個點
           All[i].Lines[j].attribute='V';//直接判斷所有輸入的線段為明筆             
        }
     }   
   
    fclose(fp);
/*判斷*/
   
    for(i=0;i<37;i++)
    {
      All[i].Lines[0].Lnumx=1;//預設第一劃等於1
      All[i].Lines[0].Lnumy=1;//預設第一線段等於1
      for(j=1;j<All[i].count;j++)
      {//後測的話J不能等於零(不能為第一劃)
        if ((j!=0)
        &&(All[i].Lines[j].stx==All[i].Lines[j-1].enx)
        &&(All[i].Lines[j].sty==All[i].Lines[j-1].eny))
        {
         All[i].Lines[j].Lnumx=All[i].Lines[j-1].Lnumx;
         All[i].Lines[j].Lnumy=All[i].Lines[j-1].Lnumy+1;//第X筆劃的的第Y+1線段                                                                                                     
         }else{
              All[i].Lines[j].Lnumx=All[i].Lines[j-1].Lnumx+1;
              All[i].Lines[j].Lnumy=1;//第X+1筆劃的第1條線段
             }
      }
     }
     for(i=0;i<37;i++)//判斷明筆暗筆‧列出暗筆
     {
          for(j=1;j<All[i].count;j++)
          {
            if (All[i].Lines[j].Lnumx=All[i].Lines[j-1].Lnumx+1)//如果是新筆劃就插入暗筆
               {
                for (newline=All[i].count-1;newline>=j;newline--)//newline從後面判斷回前面
                {//將J的東西搬進J+1裡面
                 All[i].Lines[j+1].stx=All[i].Lines[j].stx;
                 All[i].Lines[j+1].sty=All[i].Lines[j].sty;
                 All[i].Lines[j+1].enx=All[i].Lines[j].enx;
                 All[i].Lines[j+1].eny=All[i].Lines[j].eny;
                 All[i].Lines[j+1].Lnumx=All[i].Lines[j].Lnumx;
                }
                All[i].count++;
               }
            else
               {
                All[i].Lines[j].attribute='H';
                All[i].Lines[j].Lnumx=All[i].Lines[j-1].Lnumx+1;
                All[i].Lines[j].Lnumy=1;
               }
          }           
     }
/*印出*/
    for(i=0;i<37;i++)
    {
     printf("符號:%s\t 線數:%d \n",All[i].s,All[i].count);//印注音符號跟線段數
         for(j=0;j<All[i].count;j++)
         {
          printf("(%d,%d)│%c│(%d,%d)\t(%d,%d)\n",
          All[i].Lines[j].Lnumx,
          All[i].Lines[j].Lnumy,
          All[i].Lines[j].attribute,
          All[i].Lines[j].stx,
          All[i].Lines[j].sty,
          All[i].Lines[j].enx,
          All[i].Lines[j].eny);
         }
      printf("-------------------------------\n");
    }
    system("pause");
 }

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

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


 
    struct Line{int Lnumx,Lnumy,stx,sty,enx,eny,attribute;
                struct Line *ptr,*next,*temp;
               };
    struct Word{
           char s[5];
           int count;
           struct Line *ptr;
           };
    struct Word All[37];

    FILE *fp;
    main ()
    {struct Line *last=NULL,*now;
     int stx,sty,enx,eny;
     int i,j;
        
         fp=fopen("D:/94413016/20070329/a.txt","r");
         for (i=0;i<37;i++) //因為已知txt檔的內容所以才可以這樣寫
         {
          fscanf(fp,"%s %d",All[i].s,&All[i].count);//將 count 讀入(位置)
          All[i].ptr=NULL;
                for(j=0;j<All[i].count;j++)
                {      
                 fscanf(fp,"%d%d%d%d",&stx,&sty,&enx,&eny);//印出線的兩個點
               
                 if(All[i].ptr==NULL)
                 {
                   All[i].ptr=(struct Line *)malloc(sizeof(struct Line));
                   last=All[i].ptr;
                   last->stx=stx;
                   last->sty=sty;
                   last->enx=enx;
                   last->eny=eny;
                   last->attribute=1;
                   last->ptr=NULL;
                 }else{
                         last->ptr=(struct Line *)malloc(sizeof(struct Line));
                         last=last->ptr;
                         last->stx=stx;
                         last->sty=sty;
                         last->enx=enx;
                         last->eny=eny;
                         last->attribute=0;
                         last->ptr=NULL;                     
                       }
                       now=now->ptr;              
                   }

          }
       for(i=0;i<37;i++)
        {
         now=All[i].ptr;
         while (now=NULL)
               {
                 if(now->ptr!=NULL)
                 {
                   next=now->ptr;
                   if((now->ex!=next->sx)||(now->ey!=next->sy))
                       temp=(struct Line *)malloc(sizeof(struct Line));
                       temp->sx=now->ex;             
                       temp->sy=now->ey;
                       temp->ex=now->sx;
                       temp->ey=now->sy;
                       temp->attribute=0;
                       temp->ptr=NULL;
                       temp->ptr=now->ptr;
                       now->p=temp;
                 }
                   now=now->ptr; 
               }
        }
         
        for(i=0;i<37;i++)
        {
         now=All[i].ptr;
         printf("--------------------------\n");
         printf("符號:%s\t筆劃:%d\n",All[i].s,All[i].count);
         while (now!=NULL){
               printf("(%d,%d)\t(%d,%d)\n",now->stx,now->sty,now->enx,now->eny);
              
               now=now->ptr;
               }
        }
        system("pause");
    }

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

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
int count=0;
static void H(int n,char A,char B,char C)
{
 
 if (n == 1)
   {
    printf("從 Disk %d 盤 , 從 %c 移動到 → %c\n",n,A,C);
    count++;    
    }
 else
   {
    H(n - 1, A, C, B);
    printf("從 Disk %d 盤 , 從 %c 移動到 → %c\n",n,A,C);
    H(n-1,B,A,C);
    count++;   
   }
}

main()
{
 int n;
 char A='A',B='B',C='C';
  printf("請輸入一個數 n : ");
  scanf("%d",&n); 
  H(n,A,B,C);
  printf(" N = %d ,共搬移 %d 次",n,count);
  system("pause");
}

 

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

Assume that you have available to you a 360-type computer and the following available input decks:

Deck A : A Basic Assembly Language (BAL) assembler written in binary code (machine language)

Deck B : A FORTRAN to BAL translator, written in BAL

Deck C : A FORTRAN program that will read data cards and print the square roots of the data

Deck D : A data deck for the square root program of deck C

In order to compute the square roots you will have to make four computer runs. The runs are described schematically below. Each run involves (reading from left to right ) an input deck that will be operated on by a program to produce an output deck. Of course, the output deck produced by one run may be used either the input deck or the program of a subsequent run.

In the figure below identify the unlabelled decks with the letters A,B,C,D,E,F,G.

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

  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:我在寫啥
  • 請輸入密碼:
  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:寫得很....
  • 請輸入密碼:
03/29題目


1.          寫一程式,將37個標準注音符號字形讀入,並做到以下功能:
l   將指定的注音符號內的線段按順序列出
 
2.          修改一的程式,做到以下功能:
l   將指定的注音符號內的筆劃,以線段表示順序列出
 
3.          修改二的程式,做到以下功能:
l   將指定的注音符號內的明暗筆劃,以線段表示順序列出
 
4.          修改三的程式,做到同功能,但以最節省的指標資料結構完成
 

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

日期: 04/02 /2007
範圍:一到三章

加油!!!

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

指標的用法

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

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
int main()
{
int a[20];
char b[10];
int c[26];
int i;

char *p,*q;


for(i=0;i<20;i++)
    printf("a[%d]的位址: %d\t\t\t",i,&a[i]);
printf("\n");

for(i=0;i<10;i++)
    printf("b[%d]的位址: %d\t\t\t",i,&b[i]);
printf("\n");

for(i=0;i<26;i++)
{
    c[i]='A'+i;
    printf("c[%d]的字母: %c\t",i,c[i]);
}
printf("\n");
p= q= (char *)malloc(26);
for(i=0;i<26;i++)
{
     *p='A'+i;
     printf("P的初值: %d \t P的位址 %d \t %c \n",p,&p,*p);
     p++;
}free(q);
system("pause");   
}

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

  • 這是一篇加密文章,請輸入密碼
  • 密碼提示:Who am I?
  • 請輸入密碼:

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