1. 程式人生 > >PAT 乙級 1010 題解 (Basic Level) Practice

PAT 乙級 1010 題解 (Basic Level) Practice

一開始想的情況太多,走了些彎路。

#include<stdio.h>
int main()
{
    int i=20000;
    int i1,i2;
    while(2 == scanf("%d%d",&i1,&i2))
    {
        if(i2 == 0)
            break;
        if(i != 20000)
            printf(" ");
        i1 = i1*i2;
        i2 = i2-1;
        printf("%d %d",i1, i2);
        i = i2;
    }
    if(i == 20000) printf("0 0");
    return 0;
}