#include <stdio.h>
#include <stdlib.h>
#define BUF_SIZE 128
int name_pc(char* buf) {
FILE *p = popen("hostname", "r");
if (p == NULL)
return 0;
int r = 1;
if (!fgets(buf, BUF_SIZE, p))
r = 0;
pclose(p);
return r;
}
int main(int argc, char* argv[]) {
char hostname[BUF_SIZE];
if (!name_pc(hostname)) {
fputs("Error!", stderr);
return EXIT_FAILURE;
}
printf("%s\n", hostname);
return EXIT_SUCCESS;
}
Node root = {T{}, nullptr, nullptr};
Node root{T{}, nullptr, nullptr};
f F форматирует число с плавающей запятой в виде [-]d.d, где d - произвольные десятичные числа
double d, l, s, pi; /*Объявляем пременные*/
int r = 0;
pi = 3.14159;
printf("Enter radius of your circle:\n");
scanf("%d", &r);
printf("%.2f is the diameter of your circle\n", d = 2 * r); // %.[кол-во знаков]f
printf("%.2f fis the perimeter of your circle\n", l = 2 * pi * r);
printf("%.2f is the square of your circle\n", s = pi * (r * r));
Enter radius of your circle: 10
20.00 is the diameter of your circle
62.83 fis the perimeter of your circle
314.16 is the square of your circle
а в visual studio выдает ошибку?
|
даст нужное регулярное выражение. <?php
$phrases = [
'Hello world',
'Lorem ipsum',
'Just some test phrase',
'Phrase with special "|" chars',
];
$tests = array_merge($phrases, [
'Some other text',
'It should not match',
]);
$regex = sprintf('/^%s$/i', implode('|', array_map(function ($v) {
return preg_quote($v, '/');
}, $phrases)));
echo $regex . "\n";
array_walk($tests, function ($phrase) use ($regex) {
echo sprintf('%s: %s' . "\n", $phrase, preg_match($regex, $phrase) ? 'Matches' : 'Does not match');
});
x = float(a) / 4.;