Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void input(int userNumbers[] ){
- for(int i = 0; i<9; i++){
- cin >> userNumbers[i];
- if((userNumbers[i] == 0) || (i == 9)){
- break;
- }
- }
- }
- void resetArray(int userNumbers[]){
- for(int i = 0; i < 10;i++){
- userNumbers[i]=0;
- }
- }
- int findMaxValue(int numValue, int numbers[]){
- int maxValue = 0;
- for(int i = 0; i <= numValue;i++){
- if(numbers[i] > maxValue){
- maxValue = numbers[i];
- }
- }
- return maxValue;
- }
- void output (int x, string symbol, int arr){
- while(x < arr){
- cout << symbol;
- x++;
- }
- }
- void typeMan(int numValue, int maxNum, int numbers[]){
- int x;
- string symbol = " ";
- for(int i = 0;i < numValue;i++){
- cout << endl;
- if(numbers[i] < maxNum){
- symbol = " ";
- x = (maxNum + numbers[i])/2;
- output(x,symbol,maxNum);
- }
- symbol = "*";
- x=0;
- output(x, symbol,numbers[i]);
- }
- }
- int findEndOfTheLine(int userNum[]){
- int endLine = 0;
- for(int i = 0; i < 9;i++){
- if((userNum[i] == 0) || (i == 9)){
- endLine = i;
- break;
- }
- }
- return endLine;
- }
- int main()
- {
- int maxNum = 0,valueOfUserNum = 0, arrSize = 10 ;
- int userNumbers[arrSize];
- while(1 > 0){
- cout << endl << "Enter numbers to build a star man. Type 0 to complete input. (10 numbers max)" << endl;
- maxNum = 0;
- resetArray(userNumbers);
- cout << endl;
- input(userNumbers);
- valueOfUserNum = findEndOfTheLine(userNumbers);
- cout << "Here your picture:" << endl;
- maxNum = findMaxValue(valueOfUserNum,userNumbers);
- typeMan(valueOfUserNum, maxNum, userNumbers);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement