Last login: Tue May 02 2017 23:42:11 +0900 from KD106154090090
Oracle Corporation     SunOS 5.11      11.3    January 2017

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Solaris11:
  - Computer Exercise Room 1 and 2  ... std1dc2 - std1dc46, std2dc2 - std2dc46
  - Computer Exercise Room 3 and 4  ... std34rsv1 - std34rsv5
  - Standard Environment Server     ... solsv171 - solsv174
- OS X 10.9:
  - Computer Exercise Room 5 and 6  ... std5dc2 - std5dc50, std6dc2 - std6dc50
  - iLab 1 and 2                ... ilab1dc2 - ilab1dc49, ilab2dc2 - ilab2dc49
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sshsv172{s1240136}51: cd Algo1/Lec03/
sshsv172{s1240136}52: emacs B.c


















































































Last login: Tue May 02 2017 23:42:11 +0900 from KD106154090090
Oracle Corporation     SunOS 5.11      11.3    January 2017

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Solaris11:
  - Computer Exercise Room 1 and 2  ... std1dc2 - std1dc46, std2dc2 - std2dc46
  - Computer Exercise Room 3 and 4  ... std34rsv1 - std34rsv5
  - Standard Environment Server     ... solsv171 - solsv174
- OS X 10.9:
  - Computer Exercise Room 5 and 6  ... std5dc2 - std5dc50, std6dc2 - std6dc50
  - iLab 1 and 2                ... ilab1dc2 - ilab1dc49, ilab2dc2 - ilab2dc49
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sshsv172{s1240136}51: cd Algo1/Lec03/
sshsv172{s1240136}52: emacs B.c


































File Edit Options Buffers Tools C Help
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct{
  char name[10];
  int time;
}set;
struct node{
  set data;
  struct node *next;
};
struct node* insert(set);
struct node* finditem(set);
struct node* make_1node(set,struct node*);
void delnode(struct node*);
struct node *head;

int main(){
  int n, q, time=0, i; //n->?????° q->??????????????? time->????????????
  char c,cc;
-UUU:**--F1  B.c            Top L4     (C/l Abbrev) 11:42PM 21.83 --------------









































File Edit Options Buffers Tools Minibuf Help
  struct node *m, *lastnode;
  /*scanf("%c",&c);
  if(c >= '0' && c <= '9'){
    n = atoi(&c);
    while(c != ' '){
      scanf("%c",&c);
      n = 10 * n + atoi(&c);
    }
  */
  if(1){
    scanf("%d",&n);
    head = make_1node(input,NULL);
    scanf("%d",&q);
    for(i=0; i<n; i++){
      scanf("%s%d",input.name,&input.time);
      lastnode = insert(input);
    }
    while(n){
      m = head->next;
      if(m->data.time > q){
        time += q;
        m->data.time -= q;
        //???????????????-->???????°??????????
        lastnode->next = m;
        lastnode = m;
        head->next = m->next;
        m->next = NULL;
      }
      else{
        time += m->data.time;
        m->data.time = 0;
        printf("%s %d\n",m->data.name,time);
        head->next = m->next;
        free(m);
        n--;
      }
    }
-UUU:**--F1  B.c            21% L43    (C/l Abbrev) 11:43PM 21.78 --------------

Last login: Tue May 02 2017 23:42:11 +0900 from KD106154090090
Oracle Corporation     SunOS 5.11      11.3    January 2017

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Solaris11:
  - Computer Exercise Room 1 and 2  ... std1dc2 - std1dc46, std2dc2 - std2dc46
  - Computer Exercise Room 3 and 4  ... std34rsv1 - std34rsv5
  - Standard Environment Server     ... solsv171 - solsv174
- OS X 10.9:
  - Computer Exercise Room 5 and 6  ... std5dc2 - std5dc50, std6dc2 - std6dc50
  - iLab 1 and 2                ... ilab1dc2 - ilab1dc49, ilab2dc2 - ilab2dc49
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sshsv172{s1240136}51: cd Algo1/Lec03/
sshsv172{s1240136}52: emacs B.c
sshsv172{s1240136}53: gcc B.c
sshsv172{s1240136}54: ./a.out
















































5 100
p1 150
p2 400
^C
sshsv172{s1240136}55: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}56: emacs B.c











































































































































5 100
p1 150
p2 400
^C
sshsv172{s1240136}55: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}56: emacs B.c





























































File Edit Options Buffers Tools Minibuf Help
      lastnode = insert(input);
    }
    while(n){
      m = head->next;
      if(m->data.time > q){
        time += q;
        m->data.time -= q;
        //????????´??°
        lastnode->next = m;
        lastnode = m;
        head->next = m->next;
        m->next = NULL;
      }
      else{
        time += m->data.time;
        m->data.time = 0;
        printf("%s %d\n",m->data.name,time);
        head->next = m->next;
        free(m);
        n--;
      }
    }
    for(m=head->next; m!=NULL; m=m->next)
      printf("%s %d\n",m->data.name,m->data.time);
  }
  else
    {
      while(c != '\n'){
        printf("%c",c);
        scanf("%c",&c);
      }
      printf("\n");
    }
  return 0;

}
-UUU:**--F1  B.c            38% L46    (C/l Abbrev) 11:52PM 21.66 -----------------

5 100
p1 150
p2 400
^C
sshsv172{s1240136}55: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}56: emacs B.c
sshsv172{s1240136}57: ./a.out
too large
^C
sshsv172{s1240136}58: emacs B.c







































































































































5 100
p1 150
p2 400
^C
sshsv172{s1240136}55: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}56: emacs B.c
sshsv172{s1240136}57: ./a.out
too large
^C
sshsv172{s1240136}58: emacs B.c

























































File Edit Options Buffers Tools C Help
        printf("%s %d\n",m->data.name,time);
        head->next = m->next;
        free(m);
        n--;
      }
    }
    for(m=head->next; m!=NULL; m=m->next)
      printf("%s %d\n",m->data.name,m->data.time);
  }
  else
    {
      while(1){
        printf("%c",c);
        scanf("%c",&c);
        if(c == '\n') break;
      }
      printf("\n");
    }
  return 0;

}

struct node* insert(set keydata)
{
  struct node *newnode;
  struct node *n;
  if (finditem(keydata) == NULL) {
    n = head;
    while(n->next != NULL)
      n = n->next;
    newnode = make_1node(keydata, n);
    n->next = newnode;
    newnode->next = NULL;
    return newnode;
  }
  else return NULL;
-UUU:----F1  B.c            52% L69    (C/l Abbrev) 11:56PM 22.26 -----------------

5 100
p1 150
p2 400
^C
sshsv172{s1240136}55: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}56: emacs B.c
sshsv172{s1240136}57: ./a.out
too large
^C
sshsv172{s1240136}58: emacs B.c
sshsv172{s1240136}59: gcc B.c
sshsv172{s1240136}60: ./a.out
too
too
sshsv172{s1240136}61: ./a.out
too large
too large
sshsv172{s1240136}62: emacs B.c































































































































5 100
p1 150
p2 400
^C
sshsv172{s1240136}55: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}56: emacs B.c
sshsv172{s1240136}57: ./a.out
too large
^C
sshsv172{s1240136}58: emacs B.c
sshsv172{s1240136}59: gcc B.c
sshsv172{s1240136}60: ./a.out
too
too
sshsv172{s1240136}61: ./a.out
too large
too large
sshsv172{s1240136}62: emacs B.c

















































File Edit Options Buffers Tools C Help
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct{
  char name[10];
  int time;
}set;
struct node{
  set data;
  struct node *next;
};
struct node* insert(set);
struct node* finditem(set);
struct node* make_1node(set,struct node*);
void delnode(struct node*);
struct node *head;

int main(){
  int n, q, time=0, i; //n->?????° q->??????????????? time->????????????
  char c,cc;
  set input={{1,1},0}; //head??????????????¨??\???????????¨
  struct node *m, *lastnode;
  scanf("%c",&c);
  if(c >= '0' && c <= '9'){
    n = atoi(&c);
    while(1){
      scanf("%c",&c);
      if(c == ' ') break;
      n = 10 * n + atoi(&c);
    }

    //if(1){
    //scanf("%d",&n);
    head = make_1node(input,NULL);
    scanf("%d",&q);
-UUU:**--F1  B.c            Top L28    (C/l Abbrev) 11:58PM 22.16 -----------------
Auto-saving...done







































File Edit Options Buffers Tools Minibuf Help
    newnode->next = NULL;
    return newnode;
  }
  else return NULL;
}

struct node* finditem(set keydata)
{
  struct node *n;
  int flag;
  for (n = head; n->next != NULL; n = n->next) {
    if (strcmp(n->next->data.name, keydata.name) == 0) return n;
  }
  return NULL;
}

struct node* make_1node(set keydata, struct node *p)
{
  struct node *n;
  n = (struct node*)malloc(sizeof(struct node));
  n->data = keydata;
  n->next = p;
  return n;
}












-UUU:**--F1  B.c            Bot L107   (C/l Abbrev) 12:01AM 22.14 -------------------

5 100
p1 150
p2 400
^C
sshsv172{s1240136}55: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}56: emacs B.c
sshsv172{s1240136}57: ./a.out
too large
^C
sshsv172{s1240136}58: emacs B.c
sshsv172{s1240136}59: gcc B.c
sshsv172{s1240136}60: ./a.out
too
too
sshsv172{s1240136}61: ./a.out
too large
too large
sshsv172{s1240136}62: emacs B.c
sshsv172{s1240136}63: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}64: emacs B.c






















































































































sshsv172{s1240136}55: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}56: emacs B.c
sshsv172{s1240136}57: ./a.out
too large
^C
sshsv172{s1240136}58: emacs B.c
sshsv172{s1240136}59: gcc B.c
sshsv172{s1240136}60: ./a.out
too
too
sshsv172{s1240136}61: ./a.out
too large
too large
sshsv172{s1240136}62: emacs B.c
sshsv172{s1240136}63: ./a.out
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
p2 180
p5 400
p1 450
p3 550
p4 800
sshsv172{s1240136}64: emacs B.c








































File Edit Options Buffers Tools C Help
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct{
  char name[10];
  int time;
}set;
struct node{
  set data;
  struct node *next;
};
struct node* insert(set);
struct node* finditem(set);
struct node* make_1node(set,struct node*);
void delnode(struct node*);
struct node *head;

int main(){
  int n, q, time=0, i; //n->?????° q->??????????????? time->????????????
  char c,cc;
  set input={{1,1},0}; //head??????????????¨??\???????????¨
  struct node *m, *lastnode;
  scanf("%c",&c);
  if(c >= '0' && c <= '9'){
    n = atoi(&c);
    while(1){
      scanf("%c",&c);
      if(c == ' ') break;
      n = 10 * n + atoi(&c);
    }

    //if(1){
    //scanf("%d",&n);
    head = make_1node(input,NULL);
    scanf("%d",&q);
-UUU:**--F1  B.c            Top L1     (C/l Abbrev) 12:02AM 22.16 -------------------
B.c has auto save data; consider M-x recover-this-file