• 沒有找到結果。

#include <stdio.h> #include <stdlib.h> #include <string.h> #define L 50 struct Node

N/A
N/A
Protected

Academic year: 2022

Share "#include <stdio.h> #include <stdlib.h> #include <string.h> #define L 50 struct Node"

Copied!
2
0
0

加載中.... (立即查看全文)

全文

(1)

C:\hw2_sol.c 2012年年年年4月月11日月 日日 下日下下下下下下下 11:05

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define L 50

struct Node {

char word[L];

struct Node *next;

};

struct Node *newNode(const char *word) {

struct Node *tmp = (struct Node*)malloc(sizeof(struct Node));

strcpy(tmp->word, word);

tmp->next = NULL;

return tmp;

}

void addWord(char *word, int *len) {

int pos = 0;

static struct Node *head = NULL;

struct Node **tmp = &head, *tmp2;

word[*len] = 0;

*len = 0;

while (*tmp!=NULL && strcmp((*tmp)->word, word)!=0) {

tmp = &(*tmp)->next;

++pos;

}

if (*tmp!=NULL) {

tmp2 = *tmp;

*tmp = (*tmp)->next;

printf("%d", pos);

} else {

tmp2 = newNode(word);

printf("%s", word);

}

tmp2->next = head;

head = tmp2;

}

int main() {

int pos = 0;

char tmp[L], get;

while (scanf("%c", &get)==1) {

if ((get>='a'&&get<='z') || (get>='A'&&get<='Z')) {

tmp[pos++] = get;

} else

-1-

(2)

C:\hw2_sol.c 2012年年年年4月月11日月 日日 下日下下下下下下下 11:05

{

if (pos)

addWord(tmp, &pos);

printf("%c", get);

} }

if (pos)

addWord(tmp, &pos);

return 0;

}

-2-

參考文獻

相關文件

Allan (Eds.), Proceedings of the 38th Conference of the International Group for the Psychology of Mathematics Education and the 36th Conference of the North American Chapter

Second graders’ concepts of place value represented by problems involving cuisenaire rods, coins, and cherries..

Based on Cabri 3D and physical manipulatives to study the effect of learning on the spatial rotation concept for second graders..

Keywords: free problem posing, spontaneous probabilistic concepts, probability concepts levels, probability

When Wasan mathematicians propose mathematics problems, two aspects of knowledge activities related to mathematics research and practice are considered: They construct Jutsu using

分類法,以此分類法評價高中數學教師的數學教學知識,探討其所展現的 SOTO 認知層次及其 發展的主要特徵。本研究採用質為主、量為輔的個案研究法,並參照自 Learning

Steen 等人(2001)所領導的量化素養設計團隊在某種程度上視 quantitative literacy 和 numeracy 為相似詞,不過和 mathematical literacy

With learning interests as predictors, the increases in mathematics achievement were greater for third- graders and girls than for fourth-graders and boys; growth in learning