_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ _ _
Imię i nazwisko Numer indeksu Login (SPOJ)
drukowanymi literami czas pisania: 45 minut
1 grudnia 2009
Zad. 1. Każde z wyróżnionych pól (___) uzupełnij co najwyżej 3 znakami, różnymi od przecinka i średnika, tak aby program po uruchomieniu wypisywał tekst: Hello (6 pkt.)
#include <stdio.h>
int main ____
int t[] = {'H', 'e', 'l', ____, ____, ____, ____, ____, ____, 'l', 'o'};
____ ( ____ i=1; t[i+3]; i+=2, i%=7)
printf ("%c", t[i+3]);
}
Zad. 2. Jaki tekst zostanie wypisany przez poniższy program? (4 pkt.)
Wynik: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#include <stdio.h>
void weird_string_copy(char *s, char *d) {
while (*d) *++s = *d++;
}
int main() {
char s1[100] = "Nothing-is-impossible";
char s2[] = "Hello-world";
weird_string_copy (s1, s2);
weird_string_copy (s1+5, &s2[2]);
printf ("%s", s1);
}
Zad. 3. Obok każdego wywołania funkcji printf, uzupełnij tekst, który zostanie wypisany. (10 pkt.)
#include <stdio.h>
int main() {
int a=1, b=2, c=3, d=1;
char s[] = {'a','b','c'}, *p = s+1;
printf ("%d", a--* b--); _ _ _ _ _ _ _ _ _
printf ("%d", (c+1) % 3 * 4 / 3); _ _ _ _ _ _ _ _ _
printf ("%d", 2 << 3); _ _ _ _ _ _ _ _ _
printf ("%d", ++c || d--); _ _ _ _ _ _ _ _ _
printf ("%d %d", c, d); _ _ _ _ _ _ _ _ _
printf ("%d", 2 ^ 6); _ _ _ _ _ _ _ _ _
printf ("%d", 2 < 7 ? 3 : 4); _ _ _ _ _ _ _ _ _
printf ("%d", 4 == 5); _ _ _ _ _ _ _ _ _
printf ("%c", *(p+1)); _ _ _ _ _ _ _ _ _
printf ("%c", *(s)+1); _ _ _ _ _ _ _ _ _
printf ("%d", &s[1]==p); _ _ _ _ _ _ _ _ _
}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _ _ _ _ _ _ _ _
Imię i nazwisko Numer indeksu Login (SPOJ)
drukowanymi literami czas pisania: 45 minut
1 grudnia 2009
Zad. 1. Każde z wyróżnionych pól (___) uzupełnij co najwyżej 3 znakami, różnymi od przecinka i średnika, tak aby program po uruchomieniu wypisywał tekst: Hello (6 pkt.)
#include <stdio.h>
int main ____
int t[] = {'H', ____, ____, ____, ____, ____, ____, 'e', 'l', 'l', 'o'};
____ ( ____ i=2; t[i+1]; i+=3, i%=7)
printf ("%c", t[i+1]);
}
Zad. 2. Jaki tekst zostanie wypisany przez poniższy program? (4 pkt.)
Wynik: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#include <stdio.h>
void weird_string_copy(char *s, char *d) {
while (*++d) *s++ = *d;
}
int main() {
char s1[100] = "Nothing-is-impossible";
char s2[] = "Hello-world";
weird_string_copy (s1, s2);
weird_string_copy (s1+4, &s2[3]);
printf ("%s", s1);
}
Zad. 3. Obok każdego wywołania funkcji printf, uzupełnij tekst, który zostanie wypisany. (10 pkt.)
#include <stdio.h>
int main() {
int a=3, b=2, c=5, d=2;
char s[] = {'x','y','z'}, *p = s+1;
printf ("%d", a--* b--); _ _ _ _ _ _ _ _ _
printf ("%d", (c+1) % 4 * 4 / 3); _ _ _ _ _ _ _ _ _
printf ("%d", 2 << 4); _ _ _ _ _ _ _ _ _
printf ("%d", --c || d++); _ _ _ _ _ _ _ _ _
printf ("%d %d", c, d); _ _ _ _ _ _ _ _ _
printf ("%d", 1 ^ 3); _ _ _ _ _ _ _ _ _
printf ("%d", 2 < 7 ? 4 : 3); _ _ _ _ _ _ _ _ _
printf ("%d", 4 == 4); _ _ _ _ _ _ _ _ _
printf ("%c", *(p+1)); _ _ _ _ _ _ _ _ _
printf ("%c", *(s)+2); _ _ _ _ _ _ _ _ _
printf ("%d", &s[1]==p); _ _ _ _ _ _ _ _ _
}