char *escapeString(char *str) {
char *result, *temp;
int i;
temp = malloc(strlen(str)*2+1);
i = 0;
while (*str) {
switch(*str) {
case '\n':
temp[i++] = '\\';
temp[i++] = 'n';
break;
case '\r':
temp[i++] = '\\';
temp[i++] = 'r';
break;
case ':':
case '$':
case '\\':
temp[i++] = '\\';
default:
temp[i++] = *str;
}
str++;
}
temp[i] = 0;
result = malloc(i+1);
strcpy(result, temp);
free(temp);
return result;
}
_ [a-z] [0-9] [=] ¬
s0 s1 s2 ok end
s1 s1 s1 ok ok
s2 ok s2 ok ok
_ in == ['a'-'z'] in == ['0'-'9'] in == ['='] ¬
s0 val := in; next; s1 val := in-'0'; next; s2 next; ret(ASSIGN) ret(EOT)
s1 val := concat(val, in); next; s1 val := concat(val, in); next; s1 ret(IDENT, val) ret(IDENT, val)
s2 ret(INTEGER, val) val := val*10+in-'0'; next; s2 ret(INTEGER, val) ret(INTEGER, val)
s0 ('a') -> val := 'a'; next; s1
s1 ('1') -> val := 'a1'; next; s1
s1 ('=') -> ret(IDENT, 'a1')
s0 ('=') -> next; ret(ASSIGN)
s0 ('9') -> val := 9; next; s2
s2 ('5') -> val := 95; next; s2
s2 (¬) -> ret(INTEGER, 95)
s0 (¬) -> ret(EOT)
@_main proc near
push ebp
mov ebp,esp
add esp,-12
mov dword ptr [ebp-4],1998
mov dword ptr [ebp-8],2000
mov dword ptr [ebp-12],5
call @__getch
mov esp,ebp
pop ebp
ret
@_main endp
*j++; *p++;
j++; p++;
scanf("%s", *books[i].name);
Вы вместо указателя на имя передаёте значение первого символа, правильно:scanf("%s", books[i].name);
scanf("%d", books[i].price);
scanf("%d", books[i].page_n);
scanf("%d", books[i].pubhouse.year);
Вы вместо адреса переменной передаёте её значение, правильно:scanf("%d", &(books[i].price));
scanf("%d", &(books[i].page_n));
scanf("%d", &(books[i].pubhouse.year));
int n = Integer.parseInt(reader.readLine());
for (int i = 1; i <= n/3; i++) {
for (int j = i; j <= (n-i)/2; j++) {
System.out.println("Числа " + i + " + " + j + " + " + (n-i-j));
}
}
#define sign(x) ((x) == 0 ? 0 : ((x) > 0 ? 1 : -1))
#define vmul(i,j,k) = ((x[(j)]-x[(i)])*(y[(k)]-y[(j)])-(x[(k)]-x[(j)])*(y[(j)]-y[(i)]))
bool function isConvex(double *x, double *y, int n) {
S = sign(vmul(n-2, n-1, 0));
if ((S1 = vmul(n-1, 0, 1)) != 0 && sign(S1) != S)
return false;
for (int i = 0; i < n-2; i++)
if ((S1 = vmul(i, i+1, i+2)) != 0 && sign(S1) != S )
return false;
return true;
}