0

can my code be made shorter

#include <iostream> using namespace std; int main() { for(int alpha=0;alpha<=3;alpha++){ std::cout<<" "; } for(int beta=0;beta<=3;beta++){ std::cout<<"#"; } for(int charlie=0;charlie<=3;charlie++){ std::cout<<" "; } for(int delta=0;delta<=3;delta++){ std::cout<<"#"; } std::cout<<endl; /*#############*/ for(int alpha1=0;alpha1<=3;alpha1++){ std::cout<<" "; } for(int beta1=0;beta1<=3;beta1++){ std::cout<<"#"; } for(int charlie1=0;charlie1<=3;charlie1++){ std::cout<<" "; } for(int delta1=0;delta1<=3;delta1++){ std::cout<<"#"; } std::cout<<endl; for(int epsilon=0;epsilon<=18;epsilon++){ std::cout<<"#"; } std::cout<<endl; for(int epsilon1=0;epsilon1<=18;epsilon1++){ std::cout<<"#"; } std::cout<<endl; /*########################*/ for(int alpha2=0;alpha2<=3;alpha2++){ std::cout<<" "; } for(int beta2=0;beta2<=3;beta2++){ std::cout<<"#"; } for(int charlie2=0;charlie2<=3;charlie2++){ std::cout<<" "; } for(int delta2=0;delta2<=3;delta2++){ std::cout<<"#"; } std::cout<<endl; /*#############*/ for(int alpha3=0;alpha3<=3;alpha3++){ std::cout<<" "; } for(int beta3=0;beta3<=3;beta3++){ std::cout<<"#"; } for(int charlie3=0;charlie3<=3;charlie3++){ std::cout<<" "; } for(int delta3=0;delta3<=3;delta3++){ std::cout<<"#"; } std::cout<<endl; /*########################*/ for(int epsilon2=0;epsilon2<=18;epsilon2++){ std::cout<<"#"; } std::cout<<endl; for(int epsilon3=0;epsilon3<=18;epsilon3++){ std::cout<<"#"; } std::cout<<endl; /*########################*/ for(int alpha4=0;alpha4<=3;alpha4++){ std::cout<<" "; } for(int beta4=0;beta4<=3;beta4++){ std::cout<<"#"; } for(int charlie4=0;charlie4<=3;charlie4++){ std::cout<<" "; } for(int delta4=0;delta4<=3;delta4++){ std::cout<<"#"; } std::cout<<endl; /*#############*/ for(int alpha5=0;alpha5<=3;alpha5++){ std::cout<<" "; } for(int beta5=0;beta5<=3;beta5++){ std::cout<<"#"; } for(int charlie5=0;charlie5<=3;charlie5++){ std::cout<<" "; } for(int delta5=0;delta5<=3;delta5++){ std::cout<<"#"; } std::cout<<endl; /*########################*/ }

31st Aug 2016, 8:30 PM
Joel Maatkamp
Joel Maatkamp - avatar
2 Respostas
+ 1
Well I just didn't understand what was your purpose by writing this program?! What output do you want to make? And also when you wrote "using namespace std" you dont have to write "std::" every time you want to use cout...
31st Aug 2016, 8:43 PM
Fardad Fateh
+ 1
What an abomination. #include <iostream> using namespace std; int main(void) { for (int i = 0; i < 10; i++) { if ((i % 4 == 0) || (i % 4 == 1)) { cout << " #### ####" << endl; } else { cout << "###################" << endl; } } return 0; }
31st Aug 2016, 10:34 PM
Zen
Zen - avatar