Simulate the operation process of the sorter

Simulate the sorting process of n products by the sorter, and can grade the products according to the diameter of the products and send them to different channels, and count the number of products of each grade.
#include
using namespace std;
int main()
{ int n,r,a,b,c; a=b=c=0; cout<<"Please enter the product quantity (n):"<<endl; cin> >n; while (n!=0){ cout<<"Please enter the product diameter (r) cm:"<<endl; cin>>r; if (r<=6){ c=c+1; cout< <"Send to Channel 3"<<endl; } else if(r>6&&r<=8){ b=b+1; cout<<"Send to Channel 2"<<endl; }else{ a=a+1 ; cout<<"Send channel 1"<<endl; } n=n-1; } cout<<"The quantity of the third-class product is:"<<c<<"a"<<endl; cout<<"two The quantity of equivalent products is: "<<b<<"pcs"<<
























Guess you like

Origin blog.csdn.net/weixin_44917215/article/details/89303188