Δημοσιεύτηκε: 24 Ιούλ 2011, 20:55
από migf1
stamatiou έγραψε:
Edit2:Μπορεί κάποιος να μου εξηγήσει πώς δουλεύει αυτή η συνάρτηση;
Κώδικας: Επιλογή όλων
/* squeeze: delete all c from s */
void squeeze(char s[], char s2[])
{
int i, j;
for (i = j = 0; s[i] != '\0'; i++)
{
if (s[i] == s2[i])
{
s[j + 1] = s[i];
}
}
s[j] = '\0';
}


Γράψε αν θες αναλυτικά τι δεν καταλαβαίνεις ακριβώς από την παραπάνω συνάρτηση.

έγραψε:και επίσης δεν ξέρω πώς να υλοποιήσω την παρακάτω άσκηση, όχι λόγω κώδικα αλλά ως λογικής:
Spoiler: show
Exercise 2-5. Write the function any(s1,s2), which returns the first location in
a string s1 where any character from the string s2 occurs, or -1 if s1 contains no
characters from s2. (The standard library function strpbrk does the same job but
returns a pointer to the location.)

Εννοείς δεν καταλαβαίνεις την εκφώνηση;