Skip to content

Comments

Search for a substring#4

Open
NicholayShestakov wants to merge 2 commits intomainfrom
search_for_a_substring
Open

Search for a substring#4
NicholayShestakov wants to merge 2 commits intomainfrom
search_for_a_substring

Conversation

@NicholayShestakov
Copy link
Owner

Add

  • Search for a substring

Copy link
Collaborator

@WoWaster WoWaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ой, с ветками что-то не то. Надо сделать так, чтобы здесь были файлы только этой задачи.

Вынесите логику в отдельную функцию.


int substringCount = 0;
for (int i = 0; i < realStringSize - 1; i++) {
if (string[i] == substring[0]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если это такая оптимизация, то она почти бесполезна, лучше сделать ранний break во внутреннем цикле. Зато код будет гораздо читаемее.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants