grains: implementation with warning
This commit is contained in:
parent
7b9ceb13b1
commit
2458db6091
2 changed files with 32 additions and 0 deletions
18
cpp/grains/grains.cpp
Normal file
18
cpp/grains/grains.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "grains.h"
|
||||||
|
|
||||||
|
namespace grains {
|
||||||
|
|
||||||
|
static const index_t number_of_squares = 64;
|
||||||
|
|
||||||
|
|
||||||
|
ulong_t square(index_t index)
|
||||||
|
{
|
||||||
|
return 1ULL << (index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong_t total()
|
||||||
|
{
|
||||||
|
return (1ULL << number_of_squares) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
14
cpp/grains/grains.h
Normal file
14
cpp/grains/grains.h
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define EXERCISM_RUN_ALL_TESTS
|
||||||
|
|
||||||
|
|
||||||
|
namespace grains {
|
||||||
|
|
||||||
|
typedef unsigned long long ulong_t;
|
||||||
|
typedef unsigned int index_t;
|
||||||
|
|
||||||
|
ulong_t square(index_t index);
|
||||||
|
ulong_t total();
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue