#include<stdio.h>
/*input: 3 4 -5 2 6 1 -2 0
output:12 3 -10 1 6 0*/
int main(){
int a,b;
int flag=0;
while(scanf("%d %d",&a,&b)!=EOF){
if(b!=0){
if(flag==0)printf("%d",a*b);
else printf(" %d",a*b);
printf(" %d",b-1);
flag=1;//if b==0,this loop performs nothing.
}
}
if(flag==0)printf("0 0");
return 0;
}
This is a program that takes a polynomial(the first number of a pair is the coefficient,the second is the power) and compute its derivative in the same fashion.However,this program doesn't give me the intended result when I input 6 0 or 0 0,the result should be 0 0 in both cases. Additionally,I intend for this program to stop after one execution(one press of "Enter".How should I do that without changing entirely the code?