/* 배열한개
#include <stdio.h>
#include <string.h>
int main()
{
int a=0,b,c,i,j,t=0, top=0;
int anw[11]={0}, ab[11]={0};
char in[42]={0};
gets(in);
for(i=0;i<strlen(in);i++)//데이터 넣기(성공)
//홀수:Xy 계산값
//짝수:아로마 수 크기
{
if(in[i]=='I')
{
a+=2;
anw[a-1] = (in[i-1]-'0')*1; //숫자로
anw[a] = 1;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='V')
{
a+=2;
anw[a-1] = (in[i-1]-'0')*5;
anw[a] = 2;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='X')
{
a+=2;
anw[a-1] = (in[i-1]-'0')*10;
anw[a] = 3;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='L')
{
a+=2;
anw[a-1] = (in[i-1]-'0')*50;
anw[a] = 4;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='C')
{
a+=2;
anw[a-1] = (in[i-1]-'0')*100;
anw[a] = 5;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='D')
{
a+=2;
anw[a-1] = (in[i-1]-'0')*500;
anw[a] = 6;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='M')
{
a+=2;
anw[a-1] = (in[i-1]-'0')*1000;
anw[a] = 7;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
}
for(i=0;i<a;i+=2)//연산
{
top++;
t+=2;
if(anw[i] >= anw[i+2])//+ 완료
{
printf("[+][%d>=%d]%d:%d+%d", anw[i], anw[i+2], i+1, anw[i-1], anw[i+1]);
anw[i+1] = anw[i-1] + anw[i+1];//anw:계산할 순서(아로마 수의 크기)
ab[top] = anw[i+1]; //ab:Xy를 계산한값
printf("=%d\n", anw[i+1]);
}
if(anw[i]!=0)
{
if(anw[i] < anw[i+2])//- ERROR
{
printf("[-][%d<%d]%d:%d-%d", anw[i], anw[i+2],i+1, anw[i-1], anw[i+1]);
anw[i+1] = anw[i-1] - anw[i+1];
ab[top] = anw[i+1];
printf("=%d\n", anw[i+1]);
}
}
/*
for(j=a+2;j>=0;j-=2)
{
if(anw[j] >= anw[j-2])
{
printf("[C]%d:%d+%d", j-3, anw[j-1], anw[j-3]);
anw[j-3] = anw[j-1] + anw[j-3];
printf("=%d\n", anw[j-3]);
}
}
/*
}
printf("ANW:%d", anw[t-1]);
}
*/
/*배열 두개
#include <stdio.h>
#include <string.h>
int main()
{
int a=0,b,c,i,j,t=0, top=0;
int anw[11]={0}, ab[11]={0};
char in[42]={0};
gets(in);
for(i=0;i<strlen(in);i++)//데이터 넣기(성공)
//홀수:Xy 계산값
//짝수:아로마 수 크기
{
if(in[i]=='I')
{
a+=2;
top++
anw[a-1] = (in[i-1]-'0')*1; //숫자로
anw[a] = 1;
ab[top] = 1;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='V')
{
a+=2;
top++
anw[a-1] = (in[i-1]-'0')*5;
anw[a] = 2;
ab[top] = 2;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='X')
{
a+=2;
top++
anw[a-1] = (in[i-1]-'0')*10;
anw[a] = 3;
ab[top] = 3;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='L')
{
a+=2;
top++
anw[a-1] = (in[i-1]-'0')*50;
anw[a] = 4;
ab[top] = 4;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='C')
{
a+=2;
top++;
anw[a-1] = (in[i-1]-'0')*100;
anw[a] = 5;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='D')
{
a+=2;
top++;
anw[a-1] = (in[i-1]-'0')*500;
anw[a] = 6;
ab[top] = 6;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
else if(in[i]=='M')
{
a+=2;
top++;
anw[a-1] = (in[i-1]-'0')*1000;
anw[a] = 7;
ab[top] = 7;
printf("%d:%d\n", a-1, anw[a-1]);
printf("%d:%d\n", a, anw[a]);
}
}
/*
for(i=0;i<a;i+=2) // 연산
{
t+=2;
if(anw[i] >= anw[i+2]) //+ 완료
{
printf("[+][%d>=%d]%d:%d+%d", anw[i], anw[i+2], i+1, anw[i-1], anw[i+1]);
anw[i+1] = anw[i-1] + anw[i+1];
printf("=%d\n", anw[i+1]);
}
if(anw[i]!=0)
{
if(anw[i] < anw[i+2]) //- ERROR
{
printf("[-][%d<%d]%d:%d-%d", anw[i], anw[i+2],i+1, anw[i-1], anw[i+1]);
anw[i+1] = anw[i-1] - anw[i+1];
printf("=%d\n", anw[i+1]);
}
}
/*
for(j=a+2;j>=0;j-=2)
{
if(anw[j] >= anw[j-2])
{
printf("[C]%d:%d+%d", j-3, anw[j-1], anw[j-3]);
anw[j-3] = anw[j-1] + anw[j-3];
printf("=%d\n", anw[j-3]);
}
}
/*
}
printf("ANW:%d", anw[t-1]);
}
*/



