Advertisement
_Kripaka001_

star man functions 3

Jul 26th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void input(int userNumbers[] ){
  6.     for(int i = 0; i<9; i++){
  7.         cin >> userNumbers[i];
  8.         if((userNumbers[i] == 0) || (i == 9)){
  9.             break;
  10.         }
  11.     }
  12. }
  13.  
  14. void resetArray(int userNumbers[]){
  15.     for(int i = 0; i < 10;i++){
  16.         userNumbers[i]=0;
  17.     }
  18. }
  19.  
  20. int findMaxValue(int numValue, int numbers[]){
  21.     int maxValue = 0;
  22.     for(int i = 0; i <= numValue;i++){
  23.         if(numbers[i] > maxValue){
  24.             maxValue = numbers[i];
  25.         }
  26.     }
  27.     return maxValue;
  28. }
  29.  
  30. void output (int x, string symbol, int arr){
  31.     while(x < arr){
  32.         cout << symbol;
  33.         x++;
  34.     }
  35. }
  36.  
  37. void typeMan(int numValue, int maxNum, int numbers[]){
  38.     int x;
  39.     string symbol = " ";
  40.     for(int i = 0;i < numValue;i++){
  41.         cout << endl;
  42.  
  43.         if(numbers[i] < maxNum){
  44.             symbol = " ";
  45.             x = (maxNum + numbers[i])/2;
  46.             output(x,symbol,maxNum);
  47.         }
  48.         symbol = "*";
  49.         x=0;
  50.         output(x, symbol,numbers[i]);
  51.         }
  52.     }
  53.  
  54.  
  55. int findEndOfTheLine(int userNum[]){
  56.     int endLine = 0;
  57.     for(int i = 0; i < 9;i++){
  58.         if((userNum[i] == 0) || (i == 9)){
  59.             endLine = i;
  60.             break;
  61.         }
  62.     }
  63.     return endLine;
  64. }
  65.  
  66. int main()
  67. {
  68.     int maxNum = 0,valueOfUserNum = 0, arrSize = 10 ;
  69.     int userNumbers[arrSize];
  70.  
  71.     while(1 > 0){
  72.         cout << endl << "Enter numbers to build a star man. Type 0 to complete input. (10 numbers max)" << endl;
  73.         maxNum = 0;
  74.         resetArray(userNumbers);
  75.  
  76.         cout << endl;
  77.  
  78.         input(userNumbers);
  79.         valueOfUserNum = findEndOfTheLine(userNumbers);
  80.  
  81.         cout << "Here your picture:" << endl;
  82.         maxNum = findMaxValue(valueOfUserNum,userNumbers);
  83.         typeMan(valueOfUserNum, maxNum, userNumbers);
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement