C++ examples for Language Basics:Console
Print Letter Pyramid
#include <iostream> #include <string> int main(int argc, const char* argv[]) { std::string base = "abcdefghijklmnopqrstuvwxyz"; for (size_t i = 0, j = 1; i < 14; ++i, j += 2) { std::cout << std::string(14 - i, ' '); for (size_t k = 0, l = i; k < j; ++k) { std::cout << base[l];//from w ww. java 2 s. c o m if (l == base.length()) std::cout << '{'; ((k >= i) ? --l : ++l); } std::cout << std::endl; } return 0; }