-
Notifications
You must be signed in to change notification settings - Fork 0
Control works c #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a610391
c555dea
f349b9f
bd40196
1353c29
7c6effc
1e3dc48
da3011b
1d9f590
17f11ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #include <stdio.h> | ||
|
|
||
| // функция суммы четных чисел фибоначчи | ||
| int evenFibonachchi() | ||
| { | ||
| // индекс для текущего числа фибоначчи, сразу с двойки начал | ||
| int index = 3; | ||
| int formerNumberFib = 1; | ||
| int numberFib = 2; | ||
| int sum = 0; | ||
|
|
||
| // прибавляет каждое третье число фибоначчи, так как оно четно | ||
| while (numberFib < 1000000) { | ||
| if (index % 3 == 0) { | ||
| sum += numberFib; | ||
| } | ||
| index++; | ||
| numberFib += formerNumberFib; | ||
| formerNumberFib = numberFib - formerNumberFib; | ||
| } | ||
| return sum; | ||
| } | ||
|
|
||
| int main(int argc, char** argv) | ||
| { | ||
| printf("%d\n", evenFibonachchi()); | ||
| return 0; | ||
| } |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 9 баллов, -1 получен за смешение логики и ввода-вывода. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
|
|
||
| void palindrome(char* str) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. По стайлгайду вообще |
||
| { | ||
| // индексы для сравнения элементов строк | ||
| int start = 0; | ||
| int finish = strlen(str) - 1; | ||
| bool flag = true; | ||
|
|
||
| while (finish > start) { | ||
|
|
||
| // игнорирование пробелов и переход на следующий индекс | ||
| while (str[start] == ' ') { | ||
| start++; | ||
| } | ||
| while (str[finish] == ' ') { | ||
| finish--; | ||
| } | ||
| if (str[start] != str[finish]) { | ||
| flag = false; | ||
| break; | ||
| } | ||
| start++; | ||
| finish--; | ||
| } | ||
|
|
||
| if (flag) { | ||
| printf("Строка палиндром\n"); | ||
| } else { | ||
| printf("Строка не палиндром\n"); | ||
| } | ||
|
Comment on lines
+28
to
+32
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ну нет, это должно быть в |
||
| } | ||
|
|
||
| int main(int argc, char** argv) | ||
| { | ||
| // проверка палиндрома | ||
| char* strPalindrome = "l wqe req wl"; | ||
| palindrome(strPalindrome); | ||
|
|
||
| // проверка не палиндрома | ||
| char* strNotPalindrome = "iui guvv vhv"; | ||
| palindrome(strNotPalindrome); | ||
| return 0; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Удивительно всё хорошо. 10 баллов.