Minimum product (basic type)

Source: Internet
Author: User

1#include <stdio.h>2 3 intMain ()4 {5     inti,j,k;6     intT,n;//T: number of data groups N: The number of rows per row in each set of data7     inta[2][8];//two rows of data in each set of data that is used to store input8     intTemp//Intermediate temporary variable in the process for sorting each row of data9     intSum//used to record the sum of the product of two rows of dataTen      Onescanf"%d", &t);//number of input data groups A      -      for(i=t;i>0; i--)//grouping input and processing -     { thesum=0;//Clear 0 Product and -           -scanf"%d", &n);//Enter the number of rows per row in two rows of data -          +          for(j=0;j<2; j + +)//enter two rows of data -              for(k=0; k<n;k++) +scanf"%d",&a[j][k]); A  at         /*********************************************************************** - * * To achieve the minimum product, you only need to find the two rows of data not multiplied by the maximum and the minimum value multiplication, - * * Then add, so the two rows of data are sorted in descending and ascending order -         ***********************************************************************/ -          for(j=0; j<n-1; j + +)//Sort Two rows of data in descending order and ascending order by using bubble Sort method -              for(k=j+1; k<n;k++) in             { -                 if(a[0][k]>a[0][J])//Descending to                 { +temp=a[0][j]; -a[0][j]=a[0][k]; thea[0][k]=temp; *                 } $                 if(a[1][k]<a[1][J])//AscendingPanax Notoginseng                 { -temp=a[1][j]; thea[1][j]=a[1][k]; +a[1][k]=temp; A                 } the             } +              -          for(j=0; j<n;j++)//multiply the elements of the same subscript in two rows of data, and then add and Sum $sum+=a[0][j]*a[1][j]; $  -printf"%d\n", sum);//output minimum product and -     } the      -     return 0;Wuyi}

Minimum product (basic type)

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.