if len(sys.argv) <= 3 and sys.argv[1] == '--key':
if sys.argv[2] not in storage:
if sys.argv[2] in storage:
with open(storage_path, 'w') as f:
storage.get(key[sys.argv[2]])
def key_and_value(dictionary, key, value):
dictionary.update(key, value)
mylast :: [a]->[a]
mylast [] = []
mylast [z] = [z]
mylast [z,y] = [y, z]
mylast [z, y, m] = [m,y,z]
mylast (z:y:m) = mylast m ++ [y,z]
mylast :: [a]->[a]
mylast (x:xs) = mylast xs ++ [x]
mylast [] = []
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
artist := "Madonna"
token := "5936fb55e90cdd9938f8e7086c783c40"
url := fmt.Sprintf(
"http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=%s&api_key=%s&format=json", artist, token)
res, err := http.Get(url)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
var pretty bytes.Buffer
err = json.Indent(&pretty, body, "", "\t")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v\n", string(pretty.Bytes()))
}
char symbl=0;
char* Symb = &symbl;
printf("Input = \n");
scanf("%s", Symb);
char ss = 0;
char* S = &ss;
scanf("%s", S);
if (!glfwWindowShouldClose(pWindow))
{
isClosed = true;
glfwTerminate();
return;
}
readIntList :: IO [Int]
readIntList = do
line <- getLine
let ws = words line
ints = map read ws
return ints
readIntList :: IO [Int]
readIntList = fmap (map read . words) getLine
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "htable.h"
typedef struct {
uint32_t hash;
char *var;
int val;
} varnode_t;
uint32_t varnode_hash(hnode_t *_node) {
varnode_t *node = (varnode_t*)_node;
return default_hash_func((uint8_t*)node->var, strlen(node->var));
}
bool varnode_keyeq(hnode_t *_node1, hnode_t *_node2) {
varnode_t *node1 = (varnode_t*)_node1;
varnode_t *node2 = (varnode_t*)_node2;
return !strcmp(node1->var, node2->var);
}
void varnode_free(hnode_t *_node) {
varnode_t *node = (varnode_t*)_node;
free(node->var);
}
typedef struct {
char *input;
size_t input_size;
size_t offset;
char *var;
int val;
} parser_t;
void rollback(parser_t *p) {
if(p->var) {
free(p->var);
p->var = NULL;
}
}
bool get_var(parser_t *p) {
size_t init_offset = p->offset;
while(p->offset++ < p->input_size) {
if(p->input[p->offset] == ' ') {
p->input[p->offset] = '\0';
p->var = strdup(p->input + init_offset);
if(!p->var) {
perror("failed to allocate memory");
return false;
}
p->input[p->offset] = ' ';
while(p->input[p->offset] == ' ' && p->offset < p->input_size)
p->offset++;
return true;
} else if(p->input[p->offset] < 'a' || p->input[p->offset] > 'z') {
fputs("error: non-letter character in variable name\n", stderr);
return false;
}
}
return false;
}
bool check_eq(parser_t *p) {
if(p->input[p->offset++] != '=') {
fputs("error: expected '=' sign\n", stderr);
return false;
}
while(p->input[p->offset] == ' ' && p->offset < p->input_size)
p->offset++;
return true;
}
bool get_val(parser_t *p) {
if(p->input[p->offset] == '-')
p->offset++;
size_t init_offset = p->offset;
while(p->offset < p->input_size) {
if(p->input[p->offset] < '0' || p->input[p->offset] > '9') {
fputs("error: non-digital character in expression\n", stderr);
return false;
}
p->offset++;
}
p->val = atoi(p->input + init_offset);
return true;
}
int main() {
char buf[256];
parser_t parser = {
.input = buf,
.var = NULL
};
htable_t *vars = htable_create(sizeof(varnode_t), 8,
varnode_hash,
varnode_keyeq,
varnode_free);
if(!vars)
return 2;
while(fgets(buf, sizeof(buf)-1, stdin)) {
parser.offset = 0;
parser.input_size = strlen(buf);
if(buf[parser.input_size-1] == '\n') {
buf[parser.input_size-1] = '\0';
parser.input_size--;
}
if(strstr(buf, "print")) {
size_t off = 5;
while(buf[off] == ' ' && off < parser.input_size)
off++;
varnode_t findvar = {
.var = buf + off
};
varnode_t *var = (varnode_t*)htable_lookup(vars, (hnode_t*)&findvar);
if(!var) {
fprintf(stderr, "error: undefined variable %s\n", findvar.var);
continue;
}
printf("%s = %d\n", var->var, var->val);
continue;
}
if(!get_var(&parser) ||
!check_eq(&parser) ||
!get_val(&parser)) {
rollback(&parser);
continue;
}
varnode_t *newvar = malloc(sizeof(varnode_t));
if(!newvar) {
perror("failed to allocate memory");
rollback(&parser);
continue;
}
newvar->var = parser.var;
newvar->val = parser.val;
if(!htable_insert(vars, (hnode_t*)newvar)) {
fprintf(stderr, "error: failed to insert var %s\n", newvar->var);
rollback(&parser);
free(newvar);
}
}
htable_free(vars);
}
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
typedef struct {
uint32_t hash;
} hnode_t;
typedef uint32_t (*htable_hash_func)(hnode_t*);
typedef bool (*htable_keyeq_func)(hnode_t*, hnode_t*);
typedef void (*htable_free_func)(hnode_t*);
typedef struct {
hnode_t **nodes;
size_t node_size;
size_t num_nodes;
size_t max_nodes;
int size_ind;
htable_hash_func hash_func;
htable_keyeq_func keyeq_func;
htable_free_func free_func;
} htable_t;
uint32_t default_hash_func(const uint8_t *key, size_t length);
htable_t* htable_create(size_t node_size, size_t max_nodes, htable_hash_func hash_func, htable_keyeq_func keyeq_func, htable_free_func free_func);
bool htable_insert(htable_t *htable, hnode_t *node);
hnode_t* htable_lookup(htable_t *htable, hnode_t *node);
void htable_free(htable_t *htable);
int start_int();
int end_int(int start_int);
int calculate(int start_int, int end_int);
int calculate(int start_int, int end_int) {
int k = start_int; //текущий размер популяции
int n = 0; //счетчик
do {
k = k + (k / 3) - (k / 4);
n++; //инкремент счетчика
} while (k < end_int);
return n; //возврат количества итераций
}
#include <stdio.h>
#include <math.h>
#define a 5.5
#define c 2.8
#define z 4.21
#define y 28.3
#define X1 3.4
#define X2 6.6
#define DX 0.11
int main() {
int count = 0;
for(float x=X1; x<=X2; x+=DX) {
float b=5*((y-x)*sqrt(y-z*x))/(1+(y+pow(x,2))*log(z));
if (a > b && b > c) {
count++;
printf("b = %f\n", b);
}
}
printf("Количество: %d\n", count);
}
int test() {
pn[0]=f1;
pn[1]=f2;
return 0;
}
#include <stdio.h>
void p1() { puts("p1"); }
void p2() { puts("p2"); }
void p3() { puts("p3"); }
void p4() { puts("p4"); }
int main() {
void (*pn[2][2])() = {
{p1, p2},
{p3, p4},
};
for(int i = 0; i < 2; i++)
for(int j = 0; j < 2; j++)
pn[i][j]();
}
uint32_t jenkins_one_at_a_time_hash(char *key, size_t len)
{
uint32_t hash, i;
for(hash = i = 0; i < len; ++i)
{
hash += key[i];
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
instance Show ExE where
show exe = case exe of
ExData i -> "ExData " ++ show i
e1 :$: e2 -> show e1 ++ " :$: " ++ show e2
void Sprite::SetTransformation()
{
D3DXVECTOR2 spriteCenter = center;
D3DXVECTOR2 trans = pos;
D3DXVECTOR2 scaling = scale;
D3DXMatrixTransformation2D(&mat, NULL, 0.0, &scaling, &spriteCenter, rotation, &trans);
sprite->SetTransform(&mat);
}