Skip to content

Instantly share code, notes, and snippets.

@kakikubo
Created July 31, 2016 12:16
Show Gist options
  • Save kakikubo/c2418f940598c1e6dd9f73f791408019 to your computer and use it in GitHub Desktop.
Save kakikubo/c2418f940598c1e6dd9f73f791408019 to your computer and use it in GitHub Desktop.
ロジックのお勉強ですよ
#include <iostream>
using std::cin;
using std::cout;
/**
* g++ hash.cpp -o hash
*/
int main(int argc, char const* argv[]){
// こんなんが出来る
// #####
// #####
// #####
// #####
// #####
for (int row = 1; row <= 5; row++){
for (int hash = 1; hash <= 5 ; hash++){
cout << "#";
}
cout << "\n";
}
cout << "\n";
// こんなんが出来る
// #####
// ####
// ###
// ##
// #
for (int row = 1; row <= 5; row++){
for (int hash = 1; hash <= (6 - row) ; hash++){
cout << "#";
}
cout << "\n";
}
cout << "\n";
// こんなんが出来る
// #
// ##
// ###
// ##
// #
for (int row = 1; row <= 5; row++){
for (int hash = 1; hash <= (3 - abs(3 - row)) ; hash++){
cout << "#";
}
cout << "\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment