0

I need help making a tornado

i have the basics down so far but it doesnt get smaller towards the bottom. I have no clue why it wont work & writing code for every line would be a pain. here is my code so far any help would be much appreciated. void tornado(){ cout<<"\n"; int g=(10+rand()%15); int n=(1+rand()%30); for(int i=2;i<8;i++){ for(int y=0;y<n;y++){ cout<<" "; } for(int l=0;l<g;l++){ cout<<"="; } cout<<"\n" }

10th May 2018, 3:49 PM
frank
frank - avatar
4 Answers
0
You don't have enough curly brackets. Count your open curly brackets ({) and closed ones (}). There has to be the same amount. You have 4 open ones and 3 closed, meaning the error is your syntax.
2nd Jul 2018, 5:14 PM
Rain
Rain - avatar
0
I did my own version: #include <iostream> #include <cmath> //Max width is 20 and any length greater //than the height is pointless. using namespace std; void tornado(int length, int width,int decFactor){ const int totalWidth = width; for(int i = 0; i < length; i++){ for(int p = 0; p < (totalWidth - width); p++){ cout << " "; } if(width > 0){ for(int o = width*2; o > 0;o--){ cout << "="; } } cout << endl; width-= decFactor; } } int main() { int tornadoLength; cout << "Length of tornado? "; cin >> tornadoLength; cout << tornadoLength << endl; int tornadoWidth; cout << "Width of tornado? "; cin >> tornadoWidth; cout << tornadoWidth << endl << endl; int decreasingFactor = ceil((double)tornadoWidth/tornadoLength); tornado(tornadoLength,tornadoWidth, decreasingFactor); return 0; }
2nd Jul 2018, 5:59 PM
Rain
Rain - avatar
0
Rain Thank you for trying to help i would like to check this code out, however i have already solved the problem this was my conclusion on how to solve the problem:
2nd Jul 2018, 6:37 PM
frank
frank - avatar
0
void tornado(){ cout<<"\n"; int g=(10+rand()%15); int n=(1+rand()%15); int u=(1+rand()%2); int w=(2+rand()%3); for(int i=0;i<1;i++){ for(int y=0;y<n;y++){ cout<<" "; } for(int l=0;l<g;l++){ cout<<"="; } cout<<"\n"; } for(int b=0;b<g;b++){ int e=(1+rand()%2); for(int r=0;r<n+u;r++){ cout<<" "; } for(int f=0;f<g-w;f++){ cout<<"="; } cout<<"\n"; if(e==1){ w+3; u++; } if(e==2){ w++; u-3; } } }
2nd Jul 2018, 6:37 PM
frank
frank - avatar