我希望你是我独家记忆

一段永远封存的记忆,随风而去
posts - 263, comments - 31, trackbacks - 0, articles - 3
   :: 首页 :: 新随笔 ::  :: 聚合  :: 管理

HLOJ_1122

Posted on 2009-03-25 16:20 Hero 阅读(137) 评论(0)  编辑 收藏 引用 所属分类: 代码如诗--ACM
 1 //1122      Accepted     0    136    809     C++ 
 2 
 3 #include <iostream>
 4 
 5 using namespace std ;
 6 
 7 struct NODE
 8 {
 9     char name[20] ;
10     int age ;
11     struct NODE * next ;
12     struct NODE * last ;
13 };
14 
15 struct NODE *head = new struct NODE();
16 
17 int tnum ;
18 int inn ;
19 
20 int main()
21 {
22     while( scanf( "%d", &tnum ) != EOF )
23     {
24         while( tnum -- )
25         {
26             scanf( "%d", &inn ) ;
27             int age ; char name[20] ;
28             struct NODE *last = head ;
29             struct NODE *curt ;
30 
31             for( int i=1; i<=inn; i++ )
32             {
33                 cin >> name >> age ;
34                 curt = new NODE() ;
35                 curt->next = last->next ;
36                 last->next = curt ;
37                 curt->last = last ;
38                 curt->age = age ;
39                 strcpy( curt->name, name ) ;
40 
41                 last = curt ;
42             }
43 
44             while( last != head )
45             {
46                 cout << last->name << " " << last->age << endl ;
47                 curt = last ;
48                 last = last->last ;
49                 delete curt ;
50             }
51         }
52     }
53 
54     return 0 ;
55 }
56 

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理