From a8113757ef1b033f486ac8a25b3accee7d1f1abe Mon Sep 17 00:00:00 2001 From: zhangzc Date: Thu, 28 Oct 2021 16:10:27 +0800 Subject: [PATCH] update exercises --- .../solution.cpp" | 2 +- .../solution.md" | 54 +++++++++++++++++-- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\244\247\350\241\215\346\225\260\345\210\227/solution.cpp" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\244\247\350\241\215\346\225\260\345\210\227/solution.cpp" index 240a539d8..a97c9e574 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\244\247\350\241\215\346\225\260\345\210\227/solution.cpp" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\244\247\350\241\215\346\225\260\345\210\227/solution.cpp" @@ -3,7 +3,7 @@ int main() { int i; - for (i = 1; i < 20; i++) + for (i = 1; i <= 100; i++) { if (i % 2 == 0) printf("%d ", i * i / 2); diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\244\247\350\241\215\346\225\260\345\210\227/solution.md" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\244\247\350\241\215\346\225\260\345\210\227/solution.md" index 021eb6d50..1f7f316b6 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\244\247\350\241\215\346\225\260\345\210\227/solution.md" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257/\345\244\247\350\241\215\346\225\260\345\210\227/solution.md" @@ -10,7 +10,7 @@ ## aop ### before ```cpp - +#include ``` ### after ```cpp @@ -19,21 +19,65 @@ ## 答案 ```cpp - +int main() +{ + int i; + for (i = 1; i <= 100; i++) + { + if (i % 2 == 0) + printf("%d ", i * i / 2); + else + printf("%d ", (i * i - 1) / 2); + } + printf("\n"); +} ``` ## 选项 ### A ```cpp - +int main() +{ + int i; + for (i = 1; i < 100; i++) + { + if (i % 2 == 0) + printf("%d ", i * i / 2); + else + printf("%d ", (i * i - 1) / 2); + } + printf("\n"); +} ``` ### B ```cpp - +int main() +{ + int i; + for (i = 1; i <= 100; i++) + { + if (i / 2 == 0) + printf("%d ", i * i / 2); + else + printf("%d ", (i * i - 1) / 2); + } + printf("\n"); +} ``` ### C ```cpp - +int main() +{ + int i; + for (i = 1; i <= 100; i++) + { + if (i % 2 == 0) + printf("%d ", i * i % 2); + else + printf("%d ", (i * i - 1) / 2); + } + printf("\n"); +} ``` -- GitLab