This repository has been archived on 2024-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
Schule/Schleifen.cpp
2017-04-02 17:06:39 +02:00

92 lines
1.4 KiB
C++

#include<iostream>
#include<string>
#include<sstream>
int main()
{
long long depth;
std::string input;
std::cout << "Geben sie die Tiefe ein: ";
getline(std::cin, input);
std::stringstream(input) >> depth;
if(depth<2)
{
std::cout << "ERROR: Zahl muss größer als 1 sein.";
getchar();
return(1);
}
for(long long idx = 0; idx<depth*depth; idx++)
{
if(idx%depth==0) std::cout << "\n";
std::cout << "*";
}
std::cout << "\n";
for(long long idx = 0; idx<depth; idx++)
{
std::cout << "\n";
for(long long idx2 = 0; idx2<idx; idx2++)
{
std::cout << " ";
}
for(long long idx2 = 0; idx2<depth*2-1-2*idx; idx2++)
{
std::cout << "*";
}
}
std::cout << "\n\n";
for(long long idx = 0; idx<depth-1; idx++)
{
for(long long idx2 = 0; idx2<depth-idx-1; idx2++)
{
std::cout << " ";
}
std::cout << "*";
for(long long idx2 = 0; idx2<2*idx-1; idx2++)
{
std::cout << " ";
}
if(idx>0) std::cout << "*";
std::cout << "\n";
}
for(long long idx = 0; idx<2*depth-1; idx++)
{
std::cout << "*";
}
for(long long idx = 0; idx<depth-2; idx++)
{
std::cout << "\n*";
for(long long idx2 = 0; idx2<2*depth-3; idx2++)
{
std::cout << " ";
}
std::cout << "*";
}
std::cout << "\n";
for(long long idx = 0; idx<2*depth-1; idx++)
{
std::cout << "*";
}
std::cout << "\n\n\n\nProgrammende!";
getchar();
return(0);
}