前田稔(Maeda Minoru)の超初心者のプログラム入門
・・・・・・・・・8 |
8・・・・・・・・・ |
・・・・・・・・・8 |
8・・・・・・・・6 |
・・・・・・・・68 |
・・・・・・・・68 |
8・・・・・・・36 |
/*★ 2倍すると最後尾の数字が先頭に 前田 稔 ★*/ #include <iostream> #include <vector> using namespace std; int main() { vector<short> v; short n,s,c; n= 8; s=c= 0; while(s!=8) { v.push_back(n); s= n*2+c; n= s%10; c= s/10; } for(n=v.size()-1; n>=0; n--) cout << v[n]; cout << endl; return 0; } |
#include <iostream> #include <vector> using namespace std; |
{ vector<short> v; |
{ v.push_back(n); |
for(n=v.size()-1; n>=0; n--) cout << v[n]; |