RE: SLC21 Week3 - Strings in C

You are viewing a single comment's thread from:

SLC21 Week3 - Strings in C

in slc21w3sergeyk •  3 months ago 
Task Comment Grade
Practically (i.e., with code examples) explain the theory from the first part of this lesson, where the concept of two sizes of an array is discussed. Demonstrate how to make it look like the array size can be increased/decreased. All loops should work with the array size stored in the size variable. Keep the physical, actual size in the constant N. A good explanation, adding/deleting is implemented through functions, is to control array overflow/empty 3/3
Declare a string variable (store any sentence in the array). Task: reverse the string, i.e., write it backward. For example: char s[]="ABCDEF";.....your code.....cout&lt&lts; => FEDCBA "there is a ready-made swap(a,b) function that exchanges the values ​​of the variables 'Each swap places two characters in their correct position.' it was necessary to further develop this idea and explain why the loop scans the array to the middle 0.9/1
Swap neighboring letters char s[]="ABCDEF";.....your code.....cout&lt&lts; => BADCFE And here it is well explained why the cycle lasts 1 time less, I would also add an explanation that the cycle will work correctly for an even and odd number of symbols 1+/1
Shift the string cyclically to the left (it’s easier to start with this), then cyclically to the right. char s[]="ABCDEF", x[]="abrakadabra";.....your code.....cout&lt&lts&lt&lt"\n"&lt&ltx; => BCDEFA aabrakadabr I think it's easier to move to the left, so I gave the task to first move to the left and then to the right. But I think it was equally easy for you to move left and right. But it would be worth explaining why in one case we make a direct passage of the cycle, and in another case a reverse passage (from the end to the beginning, why?) 1.4/1.5
Remove all vowel letters char s[]="this is some text";...your code...cout&lt&lts; => ths s sm txt Well, you have processed the line by itself (without an additional line). But here many students are afraid - it is like sawing a branch of a tree on which you are sitting. It was necessary to clarify this situation, that there will be no trouble and everything will be fine with the line - it will not break. 1.4/1.5
Double each vowel letter char s[]="this is some text";...your code...cout&lt&lts; => thiis iis soomee teext And here a terrible mistake was made - your original line physically contains 17 characters, and it simply cannot fit more. It was necessary to take care of the reserve during the announcement. The fact that you create an array twice as long in the function is good, but at the end, when calling `strcpy`, by the way, I asked not to use library functions at all - to work only as an array. So `strcpy' will write extra characters to someone else's memory. After doubling all the vowels the modified string in `result` is copied back to the original `str` array. but in the original array there is no place to write even one additional character. 1.3/2
аAdditional task (1-2 points) - as a replacement for any of the tasks 2-6: Choose any number, preferably slightly larger than the length of the text. Increase the text length to the specified number by adding spaces between words. char s[]="this is some text";...your code...cout&lts&ltss; => (this is some text) len of s => 17 number =27
Total: 9/10
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!