Simple Calculator 1373

Multiple set of inputs expression given line, no spaces, outputs the calculation result of the expression. Test data to ensure that within the scope of int.

This is a simple problem, involving only addition and subtraction.

Enter a description:

Line expression

Output Description:

The results of the expression

Sample input:

12+21-0

Sample output:

33

 


		for(;i<len;i++){
			switch(m[i]){
				case '+':sum=sum+num[k];k=k+1;break;				
				case '-':sum=sum-num[k];k=k+1;break;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

  

Guess you like

Origin www.cnblogs.com/zq-dmhy/p/10994041.html