10700-Camel trading

Source: Internet
Author: User
Description: whether to add after-multiplication or after-Multiplication. Be sure to use long int # include <cstdio> # include <cstdlib> # include <cstring> char s [1010]. int main () {// freopen ("a.txt", "r", stdin); int n; scanf ("% d \ n", & n ); while (n --) {gets (s); long int num_min [100], num_max [100]; int max = 0, min = 0, flag = 0; int len = strlen (s); for (int I = 0; I <len; I ++) if (s [I]> = '0' & s [I] <= '9') {int c = 0, j; for (j = I; j <len; j ++) if (s [j]> = '0' & s [j] <= '9 ') c = c * 10 + s [j]-'0'; e Lse break; I = J-1; if (! Flag) {num_max [max ++] = c; num_min [min ++] = c;} else if (flag = 1) {num_min [min ++] = c; num_max [max-1] = num_max [max-1] + c;} else if (flag = 2) {num_max [max ++] = c; num_min [min-1] = num_min [min-1] * c;} else if (s [I] = '+') flag = 1; else if (s [I] = '*') flag = 2; for (int I = 1; I <max; I ++) num_max [0] = num_max [0] * num_max [I]; for (int I = 1; I <min; I ++) num_min [0] = num_min [0] + num_min [I]; printf ("The maximum and minimum are % lld and % lld. \ n ", num_max [0], num_min [0]);} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.