init commit
This commit is contained in:
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
uint64_t num;
|
||||
int free_blocks = 0;
|
||||
|
||||
while (scanf("%lx", &num) != EOF) {
|
||||
for (int i = 0; i < 64; i += 2) {
|
||||
if (((num >> i) & 0x3) == 0x0) {
|
||||
free_blocks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d\n", free_blocks);
|
||||
return 0;
|
||||
}
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
long long unsigned int tmp, res = 0;
|
||||
|
||||
while (scanf("%llu", &tmp) != EOF) {
|
||||
for (int i = 0; i < sizeof(tmp) * 8; i += 2) {
|
||||
if (!((tmp >> i) & 0x3)) {
|
||||
res++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("%llu\n", res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <wait.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int fd[2];
|
||||
pipe(fd);
|
||||
pid_t pid = fork();
|
||||
if (!pid) {
|
||||
close(fd[0]);
|
||||
dup2(fd[1], 1);
|
||||
execlp("gpg", "gpg", "-d", "--batch", "--passphrase", argv[2], "--pinentry-mode", "loopback", "--quiet",
|
||||
"--no-tty", "--no-keyring", argv[1], NULL);
|
||||
_exit(1);
|
||||
} else if (pid == -1) {
|
||||
exit(1);
|
||||
}
|
||||
close(fd[1]);
|
||||
wait(NULL);
|
||||
|
||||
dup2(fd[0], 0);
|
||||
|
||||
int tmp;
|
||||
int64_t sum = 0;
|
||||
while (scanf("%d", &tmp) != EOF) {
|
||||
sum += tmp;
|
||||
}
|
||||
|
||||
printf("%ld\n", sum);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
|
||||
volatile unsigned char cell;
|
||||
int fd[2];
|
||||
|
||||
void
|
||||
usr_hndl(int sig)
|
||||
{
|
||||
write(fd[1], &cell, 1);
|
||||
kill(getppid(), SIGUSR1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
usr_hndl1(int sig)
|
||||
{
|
||||
read(fd[0], &cell, 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
pipe(fd);
|
||||
|
||||
pid_t *mas = malloc((argc - 1) * sizeof(pid_t));
|
||||
int n = argc - 1;
|
||||
|
||||
int64_t size = 0;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
struct stat st;
|
||||
lstat(argv[i], &st);
|
||||
size = st.st_size;
|
||||
|
||||
pid_t pid = fork();
|
||||
if (!pid) {
|
||||
int file = open(argv[i], O_RDONLY);
|
||||
close(fd[0]);
|
||||
|
||||
signal(SIGUSR1, usr_hndl);
|
||||
for (;;) {
|
||||
pause();
|
||||
}
|
||||
_exit(1);
|
||||
}
|
||||
mas[i - 1] = pid;
|
||||
}
|
||||
close(fd[1]);
|
||||
|
||||
signal(SIGUSR1, usr_hndl1);
|
||||
unsigned int adr;
|
||||
while (scanf("%u", &adr) != -1) {
|
||||
kill(mas[adr % n], SIGUSR1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user