#include <stdio.h>
struct tafWorker
{
int iNumber;
int iProductCount;
struct tafWorker *pNext,*pPrev;
}
typedef stuct tafWorker worker;
worker *pHead
void main()
{
int i,j;
worker workArray[5] = {{105,0,NULL},{104,0,NULL},
{103,0,NULL},{102,0,NULL},{101,0,NULL}};
pHead = workArray;
for(i=0;i<4;++i)
{
workArray[i].pNext = Head+i+1;
if(i !=0 ) workArray[i].pPrev = head +i-1;
}
while(i!=0)
{
scanf("%d,%d",&i,&j);
InputData(i,j);
}
OutPutData(p);
}
void InputData(int iNum,int iProdCount)
{
worher *pCur=pHead,*pTmp;
while(pCur->pNext != NULL)
{
if(iNum == pCur->iNumber)
{
pCur->iProductCount += iProdCount;
pTmp = pCur;
while(pTmp = pTmp->pPrev != NULL)
{
if(pTmp->iProDuctCount > pCur->iProductCount
||(pTmp->iProDuctCount = pCur->iProductCount && pTmp->iNumber > pCur->iNumber)
{
InterChange(pCur,pTmp);
break;
}
}
}
}
}
void InterChange(worker *pCur,worker *pTmp)
{
worker workTmp;
workTmp.iNumber = *Pcur;
*pCur = *pTmp;
*pTmp = workTmp;
}
void Output(worker *p);
{
while(p != Null)
{
printf("%5d %5d\n",p->iNumber,p->iProductCount);
p=p->pNext;
}
}