Cl Email

程式 email.c email.exe

#include "rlib.c"

// === BNF Grammar =====
// S = NP VP
// NP = D N
// VP = V NP

int main(int argc, char * argv[]) {
int i;

for (i=0; i<10; i++) {

M();
S();
printf("\n");
}
}

int M() {
printf("%c", randChar("abcdefghijklmnopqustuvwxyz"));
if (randInt(10) < 8)
M();
}

int S() { NP(); VP(); }

int NP() { D(); N(); }

int VP() { V(); }

char *d[] = {"@yahoo", "@hotmail","@nqu"};
int D() { printf("%s ", randStr(d, 3)); }

char *n[] = {".edu", ".com"};
int N() { printf("%s ", randStr(n, 2)); }

char *v[] = {".tw", ".hk"};
int V() { printf("%s ", randStr(v, 2)); }


執行結果

C:\Documents and Settings\Administrator>cd \blue

C:\blue>email.exe
pqhm@hotmail .edu .hk
nfxicsxgw@nqu .com .tw
d@yahoo .edu .hk
novukpegxpu@hotmail .edu .hk
mcsy@nqu .com .tw
vkfm@nqu .edu .tw
kav@yahoo .com .tw
nk@yahoo .com .hk
xl@yahoo .edu .hk
sapofzceupaogoyfbpju@nqu .com .tw

C:\blue>


請於作業中說明 email 這個語言屬於第幾類 (Type ?) 的語言?為什麼?

屬於Type2,

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License