/*
[1] 授業単元:while, for, do-whileループ
[2] 問題文(含コード&リンク):以下
[3] 環境
[3.1] OS: (windows上のCygwin)
[3.2] コンパイラ名とバージョン: (不明)
[3.3] 言語: (C言語,,,?)
[4] 期限: (2015年1月17日)
[5] その他の制限: (例題に沿った形で解答していただきたいです,,,)
問題文及び例題は以下から
問い
整数であるnをキーボードから入力しnから1までの整数を対角に表示させなさい
実行例
Let us print n through 1 diagonally.
Enter n: 5
5
-4
--3
---2
----1
例題
整数であるnをキーボードからあたえ1からnまでの整数を対角的に表示させなさい
*/
#if 0
#include <stdio.h>
main()
{
int i, j, n;
printf("Let us print 1 through n diagonally.\n");
for (i = 1; i <= n; i++) /* i-方向(下方、「行」方向)に進む */
{
for (j = 1; j <= i; j++) /* j-方向(右、「列」方向)に進む */
{
if (j == i) /* 対角線上にあるとき */
{
printf("%d", j
); /* j = iを表示 */ }
else /* 非対角なとき */
{
}
}
}
}
#endif
#include <stdio.h>
main()
{
int i, j, n;
printf("Let us print n through 1 diagonally.\n");
for (i = 1; i <= n; i++) /* i-方向(下方、「行」方向)に進む */
{
for (j = 1; j <= i; j++) /* j-方向(右、「列」方向)に進む */
{
if (j == i) /* 対角線上にあるとき */
{
printf("%d", n
-j
+1); /* j = iを表示 */ }
else /* 非対角なとき */
{
}
}
}
}
LyoKWzFdIOaOiOalreWNmOWFg++8mndoaWxlLCBmb3IsIGRvLXdoaWxl44Or44O844OXClsyXSDllY/poYzmloco5ZCr44Kz44O844OJJuODquODs+OCrynvvJrku6XkuIsKWzNdIOeSsOWigwrjgIBbMy4xXSBPU++8miAod2luZG93c+S4iuOBrkN5Z3dpbikK44CAWzMuMl0g44Kz44Oz44OR44Kk44Op5ZCN44Go44OQ44O844K444On44Oz77yaICjkuI3mmI4pCuOAgFszLjNdIOiogOiqnu+8miAoQ+iogOiqniwsLD8pCls0XSDmnJ/pmZDvvJogKDIwMTXlubQx5pyIMTfml6XvvIkKWzVdIOOBneOBruS7luOBruWItumZkO+8miAo5L6L6aGM44Gr5rK/44Gj44Gf5b2i44Gn6Kej562U44GX44Gm44GE44Gf44Gg44GN44Gf44GE44Gn44GZLCwsKQoK5ZWP6aGM5paH5Y+K44Gz5L6L6aGM44Gv5Lul5LiL44GL44KJCgoKCgrllY/jgYQK5pW05pWw44Gn44GC44KLbuOCkuOCreODvOODnOODvOODieOBi+OCieWFpeWKm+OBl27jgYvjgokx44G+44Gn44Gu5pW05pWw44KS5a++6KeS44Gr6KGo56S644GV44Gb44Gq44GV44GECuWun+ihjOS+iwoKTGV0IHVzIHByaW50IG4gdGhyb3VnaCAxIGRpYWdvbmFsbHkuCkVudGVyIG46IDUKNQotNAotLTMKLS0tMgotLS0tMQoK5L6L6aGMCuaVtOaVsOOBp+OBguOCi27jgpLjgq3jg7zjg5zjg7zjg4njgYvjgonjgYLjgZ/jgYgx44GL44KJbuOBvuOBp+OBruaVtOaVsOOCkuWvvuinkueahOOBq+ihqOekuuOBleOBm+OBquOBleOBhAoqLwojaWYgMAojaW5jbHVkZSA8c3RkaW8uaD4KCm1haW4oKQp7CiAgICBpbnQgaSwgaiwgbjsKCiAgICBwcmludGYoIkxldCB1cyBwcmludCAxIHRocm91Z2ggbiBkaWFnb25hbGx5LlxuIik7CiAgICBwcmludGYoIkVudGVyIG46ICIpOwogICAgc2NhbmYoIiVkIiwgJm4pOwoKCiAgICBmb3IgKGkgPSAxOyBpIDw9IG47IGkrKykgLyogaS3mlrnlkJEo5LiL5pa544CB44CM6KGM44CN5pa55ZCRKeOBq+mAsuOCgCAqLwogICAgewogICAgICAgIGZvciAoaiA9IDE7IGogPD0gaTsgaisrKSAvKiBqLeaWueWQkSjlj7PjgIHjgIzliJfjgI3mlrnlkJEp44Gr6YCy44KAICovCiAgICAgICAgewogICAgICAgICAgICBpZiAoaiA9PSBpKSAvKiDlr77op5Lnt5rkuIrjgavjgYLjgovjgajjgY0gKi8KICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcHJpbnRmKCIlZCIsIGopOyAvKiBqID0gaeOCkuihqOekuiAqLwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgLyog6Z2e5a++6KeS44Gq44Go44GNICovCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHByaW50ZigiLSIpOyAvKiDjgIwt44CN44KS6KGo56S6ICovCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcHJpbnRmKCJcbiIpOyAvKiDjgaTjgY7jga7ooYzjgavnp7vjgosgKi8KICAgIH0KfQojZW5kaWYKCiNpbmNsdWRlIDxzdGRpby5oPgoKbWFpbigpCnsKICAgIGludCBpLCBqLCBuOwoKICAgIHByaW50ZigiTGV0IHVzIHByaW50IG4gdGhyb3VnaCAxIGRpYWdvbmFsbHkuXG4iKTsKICAgIHByaW50ZigiRW50ZXIgbjogIik7CiAgICBzY2FuZigiJWQiLCAmbik7CgoKICAgIGZvciAoaSA9IDE7IGkgPD0gbjsgaSsrKSAvKiBpLeaWueWQkSjkuIvmlrnjgIHjgIzooYzjgI3mlrnlkJEp44Gr6YCy44KAICovCiAgICB7CiAgICAgICAgZm9yIChqID0gMTsgaiA8PSBpOyBqKyspIC8qIGot5pa55ZCRKOWPs+OAgeOAjOWIl+OAjeaWueWQkSnjgavpgLLjgoAgKi8KICAgICAgICB7CiAgICAgICAgICAgIGlmIChqID09IGkpIC8qIOWvvuinkue3muS4iuOBq+OBguOCi+OBqOOBjSAqLwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwcmludGYoIiVkIiwgbi1qKzEpOyAvKiBqID0gaeOCkuihqOekuiAqLwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgLyog6Z2e5a++6KeS44Gq44Go44GNICovCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHByaW50ZigiLSIpOyAvKiDjgIwt44CN44KS6KGo56S6ICovCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcHJpbnRmKCJcbiIpOyAvKiDjgaTjgY7jga7ooYzjgavnp7vjgosgKi8KICAgIH0KfQ==