What is the vector diagram of a transformer?

Bean Machine (quincunx) problem using VECTOR. I cannot out put the bean machine diagram.?

  • I'm having problem at the bean machine. I got most of the part works except for the output is incorrect and I don't know why. The maxvalue function is also return the wrong value. Can someone know what is the mistakes that I've had in there please. And yes, it's a homework if you would ask :) Here is my code, i don't know what's wrong. // Bean Machine #include <iostream> #include <string> #include <vector> #include <ctime> #include<cstdlib> using namespace std; //to find which slot has the max number of balls int maxValue( vector<int> list) //, int listSize ) { int currentMax = list[0]; for (int i = 1; i< list.size(); i++) { if (list[i] > currentMax) currentMax = list[i]; } return currentMax; } int main() { int ball; int slot; cout <<"Enter the number of balls to drop: " ; cin >> ball; cout << "Enter the number of slots in the bean machine: "; cin >> slot; vector<int> bean(slot,0); // initialize all the slot have 0 balls in the beginning srand(time(0)); // loop through number of balls for (int i =0; i< ball; i++) // a function that out put the path { cout << endl; int position = 0; // number of R start with 0 in the beginning of each time for (int j = 0; j < slot; j++) { int num = rand() % 2; if (num == 1) cout << "L"; else {cout <<"R"; position = position + 1;} } //cout<<"NUM = " << position; bean[position] = bean[position] + 1; // when the ball falls into the slot, add one 0 to the slot ************ it doesn't work if this line is here. } int max = maxValue(bean); //, slot+1); // call the function to return the max number of bals cout << endl << "MAx number ball is : " << max; cout << endl<<"list [0] = " << bean[0]; cout << "list [1] = " << bean[1]; cout << "list [2] = " << bean[2]; for (int i = max; i>0; i--) // output the slot of balls { cout << endl; for(int j = 0; j < bean.size(); j++) { if (bean[j] == i || bean[j] < i) // if the value in the slot >= the max, then cout 0 to that slott cout << " 0"; else cout << " "; // leave it blank } } return 0; }

  • Answer:

    Then, restart the coding... Make sure to include the appropriate brackets.... Good luck!

minhtrang at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Then, restart the coding... Make sure to include the appropriate brackets.... Good luck!

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.