algorithm, almost blindfolded.

Source: Internet
Author: User

Pay, see how many 100,50,10,5,1 you need

#include <stdio.h>
void Main () {
int I,j,n,m,gz;long sul,su=0;
int s[8]={0,0,0,0,0,0,0,0};
int b[8]={0,100,50,20,10,5,2,1};
printf ("Please enter the number of people:");
scanf ("%d", &n);
printf ("Please enter the wages of each employee \ n");
for (i=1;i<=n;i++) {
printf ("Input of%d employee wages:", I);
scanf ("%d", &gz);
Su=su+gz;
for (j=1;j<=7;j++) {
M=GZ/B[J];
S[j]=s[j]+m;
GZ=GZ-M*B[J];
}
}
printf ("Total unit wage:%ld\n", SU);
printf ("Statistical results of each denomination: \ n");
sul=0;
for (j=1;j<=7;j++) {
printf ("%3d---%3d\n", b[j],s[j]);
SUL=SUL+B[J]*S[J];
}
if (Su==sul) printf ("Verified statistics are correct \ n");
}

algorithm, almost blindfolded.

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.