Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Ensure the translated C code behaves exactly like the original Go snippet. | package bank
import (
"bytes"
"errors"
"fmt"
"log"
"sort"
"sync"
)
type PID string
type RID string
type RMap map[RID]int
func (m RMap) String() string {
rs := make([]string, len(m))
i := 0
for r := range m {
rs[i] = string(r)
i++
}
sort.Strings(rs)
var... | #include <stdio.h>
#include <stdbool.h>
int main() {
int curr[5][5];
int max_claim[5][5];
int avl[5];
int alloc[5] = {0, 0, 0, 0, 0};
int max_res[5];
int running[5];
int i, j, exec, r, p;
int count = 0;
bool safe = false;
printf("\nEnter the number of resources: ");
scanf(... |
Convert this Go snippet to C and keep its semantics consistent. | package main
import (
"errors"
"fmt"
"strconv"
"strings"
)
func main() {
rf, err := rangeFormat([]int{
0, 1, 2, 4, 6, 7, 8, 11, 12, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 27, 28, 29, 30, 31, 32, 33, 35, 36,
37, 38, 39,
})
if err != nil {
fmt... | #include <stdio.h>
#include <stdlib.h>
size_t rprint(char *s, int *x, int len)
{
#define sep (a > s ? "," : "")
#define ol (s ? 100 : 0)
int i, j;
char *a = s;
for (i = j = 0; i < len; i = ++j) {
for (; j < len - 1 && x[j + 1] == x[j] + 1; j++);
if (i + 1 < j)
a += snprintf(s?a:s, ol, "%s%d-%d", sep... |
Write the same code in C as shown below in Go. | package main
import "fmt"
import "C"
func main() {
code := []byte{
0x55, 0x48, 0x89, 0xe5, 0x89, 0x7d,
0xfc, 0x89, 0x75, 0xf8, 0x8b, 0x75,
0xfc, 0x03, 0x75, 0xf8, 0x89, 0x75,
0xf4, 0x8b, 0x45, 0xf4, 0x5d, 0xc3,
}
le := len(code)
buf := C.mmap(nil, C.size_t(le), C.PROT... | #include <stdio.h>
#include <sys/mman.h>
#include <string.h>
int test (int a, int b)
{
char code[] = {0x8B, 0x44, 0x24, 0x4, 0x3, 0x44, 0x24, 0x8, 0xC3};
void *buf;
int c;
buf = mmap (0,sizeof(code),PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_PRIVATE|MAP_ANON,-1,0);
memcpy (buf, code, sizeof(code... |
Ensure the translated C code behaves exactly like the original Go snippet. | package main
import "fmt"
type any = interface{}
func showType(a any) {
switch a.(type) {
case rune:
fmt.Printf("The type of '%c' is %T\n", a, a)
default:
fmt.Printf("The type of '%v' is %T\n", a, a)
}
}
func main() {
values := []any{5, 7.5, 2 + 3i, 'd', true, "Rosetta"}
for ... | #include<stdio.h>
#include<ctype.h>
void typeDetector(char* str){
if(isalnum(str[0])!=0)
printf("\n%c is alphanumeric",str[0]);
if(isalpha(str[0])!=0)
printf("\n%c is alphabetic",str[0]);
if(iscntrl(str[0])!=0)
printf("\n%c is a control character",str[0]);
if(isdigit(str[0])!=0)
printf("\n%c is a digit",s... |
Write a version of this Go function in C with identical behavior. | package main
import (
"fmt"
"strconv"
"strings"
)
const t = ` 55
94 48
95 30 96
77 71 26 67
97 13 76 38 45
07 36 79 16 37 68
48 07 09 18 70 26 06
18 72 79... | #include <stdio.h>
#include <math.h>
#define max(x,y) ((x) > (y) ? (x) : (y))
int tri[] = {
55,
94, 48,
95, 30, 96,
77, 71, 26, 67,
97, 13, 76, 38, 45,
7, 36, 79, 16, 37, 68,
48, 7, 9, 18, 70, 26, 6,
18, 72, 79, 46, 59, 79, 29, 90,
20, 76, 87, 11, 32, 7, 7, 49, 18,
27, 83, 58, 35, 71, 11, 25, 57, 29... |
Change the following Go code into C without altering its purpose. | package main
import (
"bytes"
"fmt"
"strings"
)
var in = `
00000000000000000000000000000000
01111111110000000111111110000000
01110001111000001111001111000000
01110000111000001110000111000000
01110001111000001110000000000000
01111111110000001110000000000000
01110111100000001110000111000000
0111001111001110... | #include<stdlib.h>
#include<stdio.h>
char** imageMatrix;
char blankPixel,imagePixel;
typedef struct{
int row,col;
}pixel;
int getBlackNeighbours(int row,int col){
int i,j,sum = 0;
for(i=-1;i<=1;i++){
for(j=-1;j<=1;j++){
if(i!=0 || j!=0)
sum+= (imageMatrix[row+i][col+j]==imagePixel);
}
}
return... |
Write a version of this Go function in C with identical behavior. | package main
import (
"fmt"
"raster"
)
var g0, g1 *raster.Grmap
var ko [][]int
var kc []uint16
var mid int
func init() {
ko = [][]int{
{-1, -1}, {0, -1}, {1, -1},
{-1, 0}, {0, 0}, {1, 0},
{-1, 1}, {0, 1}, {1, 1}}
kc = make([]uint16, len(ko))
mid = len(ko) ... | #include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
typedef struct { unsigned char r, g, b; } rgb_t;
typedef struct {
int w, h;
rgb_t **pix;
} image_t, *image;
typedef struct {
int r[256], g[256], b[256];
int n;
} color_histo_t;
int write_ppm(image... |
Transform the following Go implementation into C, maintaining the same output and logic. | package main
import (
"fmt"
"github.com/sevlyar/go-daemon"
"log"
"os"
"time"
)
func work() {
f, err := os.Create("daemon_output.txt")
if err != nil {
log.Fatal(err)
}
defer f.Close()
ticker := time.NewTicker(time.Second)
go func() {
for t := range ticker.C {... | #include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
int
main(int argc, char **argv)
{
extern char *__progname;
time_t clock;
int fd;
if (argc != 2) {
fprintf(stderr, "usage: %s file\n", __prog... |
Change the following Go code into C without altering its purpose. | package main
import (
"fmt"
"github.com/sevlyar/go-daemon"
"log"
"os"
"time"
)
func work() {
f, err := os.Create("daemon_output.txt")
if err != nil {
log.Fatal(err)
}
defer f.Close()
ticker := time.NewTicker(time.Second)
go func() {
for t := range ticker.C {... | #include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
int
main(int argc, char **argv)
{
extern char *__progname;
time_t clock;
int fd;
if (argc != 2) {
fprintf(stderr, "usage: %s file\n", __prog... |
Write a version of this Go function in C with identical behavior. | package main
import (
"fmt"
"go/parser"
"regexp"
"strings"
)
var (
re1 = regexp.MustCompile(`[^_a-zA-Z0-9\+\-\*/=<\(\)\s]`)
re2 = regexp.MustCompile(`\b_\w*\b`)
re3 = regexp.MustCompile(`[=<+*/-]\s*not`)
re4 = regexp.MustCompile(`(=|<)\s*[^(=< ]+\s*([=<+*/-])`)
)
var subs = [][2]strin... |
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <setjmp.h>
#define AT(CHAR) ( *pos == CHAR && ++pos )
#define TEST(STR) ( strncmp( pos, STR, strlen(STR) ) == 0 \
&& ! isalnum(pos[strlen(STR)]) && pos[strlen(STR)] != '_' )
#define IS(STR) ( TEST(STR) && (pos += strlen(STR)) )
static char *pos... |
Rewrite this program in C while keeping its functionality equivalent to the Go version. | package main
import (
"fmt"
"rcu"
)
func contains(a []int, v int) bool {
for _, e := range a {
if e == v {
return true
}
}
return false
}
func main() {
const limit = 50
cpt := []int{1, 2}
for {
m := 1
l := len(cpt)
for contains(cpt, ... |
#include <stdio.h>
int Gcd(int v1, int v2)
{
int a, b, r;
if (v1 < v2)
{
a = v2;
b = v1;
}
else
{
a = v1;
b = v2;
}
do
{
r = a % b;
if (r == 0)
{
break;
}
else
{
a = b;
b = r;
}
} while (1 == 1);
return b;
}
int NotInList(int num, int numtrip, int *tripletslist)
{
for... |
Convert this Go block to C, preserving its control flow and logic. | package main
import (
"fmt"
"rcu"
)
func contains(a []int, v int) bool {
for _, e := range a {
if e == v {
return true
}
}
return false
}
func main() {
const limit = 50
cpt := []int{1, 2}
for {
m := 1
l := len(cpt)
for contains(cpt, ... |
#include <stdio.h>
int Gcd(int v1, int v2)
{
int a, b, r;
if (v1 < v2)
{
a = v2;
b = v1;
}
else
{
a = v1;
b = v2;
}
do
{
r = a % b;
if (r == 0)
{
break;
}
else
{
a = b;
b = r;
}
} while (1 == 1);
return b;
}
int NotInList(int num, int numtrip, int *tripletslist)
{
for... |
Generate an equivalent C version of this Go code. | package main
import (
"fmt"
"rcu"
)
func contains(a []int, v int) bool {
for _, e := range a {
if e == v {
return true
}
}
return false
}
func main() {
const limit = 50
cpt := []int{1, 2}
for {
m := 1
l := len(cpt)
for contains(cpt, ... |
#include <stdio.h>
int Gcd(int v1, int v2)
{
int a, b, r;
if (v1 < v2)
{
a = v2;
b = v1;
}
else
{
a = v1;
b = v2;
}
do
{
r = a % b;
if (r == 0)
{
break;
}
else
{
a = b;
b = r;
}
} while (1 == 1);
return b;
}
int NotInList(int num, int numtrip, int *tripletslist)
{
for... |
Preserve the algorithm and functionality while converting the code from Go to C. | package main
import "fmt"
func main() {
s := []int{1, 2, 2, 3, 4, 4, 5}
for i := 0; i < len(s); i++ {
curr := s[i]
var prev int
if i > 0 && curr == prev {
fmt.Println(i)
}
prev = curr
}
var prev int
for i := 0; i < len(s); i... | #include <stdio.h>
int main() {
int i, gprev = 0;
int s[7] = {1, 2, 2, 3, 4, 4, 5};
for (i = 0; i < 7; ++i) {
int curr = s[i];
int prev = 0;
if (i > 0 && curr == prev) printf("%d\n", i);
prev = curr;
}
for (i = 0; i < 7; ++i) {
int curr = s[i];
... |
Ensure the translated C code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"github.com/tiaguinho/gosoap"
"log"
)
type CheckVatResponse struct {
CountryCode string `xml:"countryCode"`
VatNumber string `xml:"vatNumber"`
RequestDate string `xml:"requestDate"`
Valid string `xml:"valid"`
Name string `xml:"name"`
Addre... | #include <curl/curl.h>
#include <string.h>
#include <stdio.h>
size_t write_data(void *ptr, size_t size, size_t nmeb, void *stream){
return fwrite(ptr,size,nmeb,stream);
}
size_t read_data(void *ptr, size_t size, size_t nmeb, void *stream){
return fread(ptr,size,nmeb,stream);
}
void callSOAP(char* URL, char *... |
Preserve the algorithm and functionality while converting the code from Go to C. |
#include<stdio.h>
#define Hi printf("Hi There.");
#define start int main(){
#define end return 0;}
start
Hi
#warning "Don't you have anything better to do ?"
#ifdef __unix__
#warning "What are you doing still working on Unix ?"
printf("\nThis is an Unix system.");
#elif _WIN32
#warning "You couldn't afford ... | |
Convert the following code from Go to C, ensuring the logic remains intact. | package main
import (
"fmt"
"math/big"
)
const (
mask0, bit0 = (1 << (1 << iota)) - 1, 1 << iota
mask1, bit1
mask2, bit2
mask3, bit3
mask4, bit4
mask5, bit5
)
func rupb(x uint64) (out int) {
if x == 0 {
return -1
}
if x&^mask5 != 0 {
x >>= bit5
out ... | #include <stdio.h>
#include <stdint.h>
uint32_t msb32(uint32_t n)
{
uint32_t b = 1;
if (!n) return 0;
#define step(x) if (n >= ((uint32_t)1) << x) b <<= x, n >>= x
step(16); step(8); step(4); step(2); step(1);
#undef step
return b;
}
int msb32_idx(uint32_t n)
{
int b = 0;
if (!n) return -1;
#define step(x) if... |
Rewrite the snippet below in C so it works the same as the original Go code. | package main
import (
"fmt"
"math/big"
)
const (
mask0, bit0 = (1 << (1 << iota)) - 1, 1 << iota
mask1, bit1
mask2, bit2
mask3, bit3
mask4, bit4
mask5, bit5
)
func rupb(x uint64) (out int) {
if x == 0 {
return -1
}
if x&^mask5 != 0 {
x >>= bit5
out ... | #include <stdio.h>
#include <stdint.h>
uint32_t msb32(uint32_t n)
{
uint32_t b = 1;
if (!n) return 0;
#define step(x) if (n >= ((uint32_t)1) << x) b <<= x, n >>= x
step(16); step(8); step(4); step(2); step(1);
#undef step
return b;
}
int msb32_idx(uint32_t n)
{
int b = 0;
if (!n) return -1;
#define step(x) if... |
Translate the given Go code snippet into C without altering its behavior. | package main
import "fmt"
func risesEqualsFalls(n int) bool {
if n < 10 {
return true
}
rises := 0
falls := 0
prev := -1
for n > 0 {
d := n % 10
if prev >= 0 {
if d < prev {
rises = rises + 1
} else if d > prev {
f... | #include <stdio.h>
int riseEqFall(int num) {
int rdigit = num % 10;
int netHeight = 0;
while (num /= 10) {
netHeight += ((num % 10) > rdigit) - ((num % 10) < rdigit);
rdigit = num % 10;
}
return netHeight == 0;
}
int nextNum() {
static int num = 0;
do {num++;} while (!ris... |
Please provide an equivalent version of this Go code in C. | package main
import (
"fmt"
"time"
"os"
"os/exec"
"strconv"
)
func main() {
tput("clear")
tput("cup", "6", "3")
time.Sleep(1 * time.Second)
tput("cub1")
time.Sleep(1 * time.Second)
tput("cuf1")
time.Sleep(1 * time.Second)
tput("cuu1")
time.Sleep(1 * time.Se... | #include<conio.h>
#include<dos.h>
char *strings[] = {"The cursor will move one position to the left",
"The cursor will move one position to the right",
"The cursor will move vetically up one line",
"The cursor will move vertically down one line",
"The cursor will move to the beginning of th... |
Write the same algorithm in C as shown in this Go implementation. | package main
import (
"fmt"
"math"
"math/rand"
"time"
)
var (
dists = calcDists()
dirs = [8]int{1, -1, 10, -10, 9, 11, -11, -9}
)
func calcDists() []float64 {
dists := make([]float64, 10000)
for i := 0; i < 10000; i++ {
ab, cd := math.Floor(float64(i)/100), float64(i%100)
... | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#define VECSZ 100
#define STATESZ 64
typedef float floating_pt;
#define EXP expf
#define SQRT sqrtf
static floating_pt
randnum (void)
{
return (floating_pt)
((double) (random () & 2147483647) / ... |
Please provide an equivalent version of this Go code in C. | package main
import "fmt"
var count = 0
func foo() {
fmt.Println("foo called")
}
func init() {
fmt.Println("first init called")
foo()
}
func init() {
fmt.Println("second init called")
main()
}
func main() {
count++
fmt.Println("main called when count is", count)
}
| #include<stdio.h>
#define start main()
int start
{
printf("Hello World !");
return 0;
}
|
Generate an equivalent C version of this Go code. | package main
import "fmt"
var count = 0
func foo() {
fmt.Println("foo called")
}
func init() {
fmt.Println("first init called")
foo()
}
func init() {
fmt.Println("second init called")
main()
}
func main() {
count++
fmt.Println("main called when count is", count)
}
| #include<stdio.h>
#define start main()
int start
{
printf("Hello World !");
return 0;
}
|
Convert this Go snippet to C and keep its semantics consistent. | package main
import (
"fmt"
"rcu"
)
func main() {
sum := 0
for _, p := range rcu.Primes(2e6 - 1) {
sum += p
}
fmt.Printf("The sum of all primes below 2 million is %s.\n", rcu.Commatize(sum))
}
| #include<stdio.h>
#include<stdlib.h>
int isprime( int p ) {
int i;
if(p==2) return 1;
if(!(p%2)) return 0;
for(i=3; i*i<=p; i+=2) {
if(!(p%i)) return 0;
}
return 1;
}
int main( void ) {
int p;
long int s = 2;
for(p=3;p<2000000;p+=2) {
if(isprime(p)) s+=p;
}
p... |
Transform the following Go implementation into C, maintaining the same output and logic. | package main
import (
"github.com/fogleman/gg"
"math"
)
var dc = gg.NewContext(512, 512)
func koch(x1, y1, x2, y2 float64, iter int) {
angle := math.Pi / 3
x3 := (x1*2 + x2) / 3
y3 := (y1*2 + y2) / 3
x4 := (x1 + x2*2) / 3
y4 := (y1 + y2*2) / 3
x5 := x3 + (x4-x3)*math.Cos(angle) + (y4... | #include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#define pi M_PI
typedef struct{
double x,y;
}point;
void kochCurve(point p1,point p2,int times){
point p3,p4,p5;
double theta = pi/3;
if(times>0){
p3 = (point){(2*p1.x+p2.x)/3,(2*p1.y+p2.y)/3};
p5 = (point){(2*p2.x+p1.x)/3,(2*p2.y+p... |
Convert this Go block to C, preserving its control flow and logic. | package main
import (
"fmt"
"image"
"image/color"
"image/draw"
"math/rand"
"time"
)
func main() {
rect := image.Rect(0, 0, 640, 480)
img := image.NewRGBA(rect)
blue := color.RGBA{0, 0, 255, 255}
draw.Draw(img, rect, &image.Uniform{blue}, image.ZP, draw.Src)
yell... | #include<graphics.h>
#include<stdlib.h>
#include<time.h>
int main()
{
srand(time(NULL));
initwindow(640,480,"Yellow Random Pixel");
putpixel(rand()%640,rand()%480,YELLOW);
getch();
return 0;
}
|
Ensure the translated C code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"strings"
)
func main() {
const (
vowels = "aeiou"
consonants = "bcdfghjklmnpqrstvwxyz"
)
strs := []string{
"Forever Go programming language",
"Now is the time for all good men to come to the aid of their country.",
}
for _, s... |
#include <stdio.h>
char vowels[] = {'a','e','i','o','u','\n'};
int len(char * str) {
int i = 0;
while (str[i] != '\n') i++;
return i;
}
int isvowel(char c){
int b = 0;
int v = len(vowels);
for(int i = 0; i < v;i++) {
if(c == vowels[i]) {
b = 1;
break;
}
}
return b;
}
int isletter(char c){
ret... |
Preserve the algorithm and functionality while converting the code from Go to C. | package main
import (
"fmt"
"strings"
)
func main() {
const (
vowels = "aeiou"
consonants = "bcdfghjklmnpqrstvwxyz"
)
strs := []string{
"Forever Go programming language",
"Now is the time for all good men to come to the aid of their country.",
}
for _, s... |
#include <stdio.h>
char vowels[] = {'a','e','i','o','u','\n'};
int len(char * str) {
int i = 0;
while (str[i] != '\n') i++;
return i;
}
int isvowel(char c){
int b = 0;
int v = len(vowels);
for(int i = 0; i < v;i++) {
if(c == vowels[i]) {
b = 1;
break;
}
}
return b;
}
int isletter(char c){
ret... |
Rewrite this program in C while keeping its functionality equivalent to the Go version. | package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
type TokenType int
const (
tkEOI TokenType = iota
tkMul
tkDiv
tkMod
tkAdd
tkSub
tkNegate
tkNot
tkLss
tkLeq
tkGtr
tkGeq
tkEql
tkNeq
tkAssign
tkAnd
tkOr
t... | count = 1;
while (count < 10) {
print("count is: ", count, "\n");
count = count + 1;
}
|
Produce a language-to-language conversion: from Go to C, same semantics. | package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
type TokenType int
const (
tkEOI TokenType = iota
tkMul
tkDiv
tkMod
tkAdd
tkSub
tkNegate
tkNot
tkLss
tkLeq
tkGtr
tkGeq
tkEql
tkNeq
tkAssign
tkAnd
tkOr
t... | count = 1;
while (count < 10) {
print("count is: ", count, "\n");
count = count + 1;
}
|
Keep all operations the same but rewrite the snippet in C. | package main
import (
"fmt"
"image"
"image/color"
"image/draw"
)
func main() {
rect := image.Rect(0, 0, 320, 240)
img := image.NewRGBA(rect)
green := color.RGBA{0, 255, 0, 255}
draw.Draw(img, rect, &image.Uniform{green}, image.ZP, draw.Src)
red := color.RGBA{255, 0, 0, ... | #include<graphics.h>
int main()
{
initwindow(320,240,"Red Pixel");
putpixel(100,100,RED);
getch();
return 0;
}
|
Transform the following Go implementation into C, maintaining the same output and logic. | package main
import (
"fmt"
"rcu"
)
func main() {
var numbers []int
for i := 2; i < 200; i++ {
bds := rcu.DigitSum(i, 2)
if rcu.IsPrime(bds) {
tds := rcu.DigitSum(i, 3)
if rcu.IsPrime(tds) {
numbers = append(numbers, i)
}
}
... | #include <stdio.h>
#include <stdint.h>
uint8_t prime(uint8_t n) {
uint8_t f;
if (n < 2) return 0;
for (f = 2; f < n; f++) {
if (n % f == 0) return 0;
}
return 1;
}
uint8_t digit_sum(uint8_t n, uint8_t base) {
uint8_t s = 0;
do {s += n % base;} while (n /= base);
return s;
}
... |
Maintain the same structure and functionality when rewriting this code in C. | package main
import (
"fmt"
"rcu"
)
func main() {
var numbers []int
for i := 2; i < 200; i++ {
bds := rcu.DigitSum(i, 2)
if rcu.IsPrime(bds) {
tds := rcu.DigitSum(i, 3)
if rcu.IsPrime(tds) {
numbers = append(numbers, i)
}
}
... | #include <stdio.h>
#include <stdint.h>
uint8_t prime(uint8_t n) {
uint8_t f;
if (n < 2) return 0;
for (f = 2; f < n; f++) {
if (n % f == 0) return 0;
}
return 1;
}
uint8_t digit_sum(uint8_t n, uint8_t base) {
uint8_t s = 0;
do {s += n % base;} while (n /= base);
return s;
}
... |
Generate a C translation of this Go snippet without changing its computational steps. | package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"sort"
"strings"
"unicode/utf8"
)
func main() {
wordList := "unixdict.txt"
b, err := ioutil.ReadFile(wordList)
if err != nil {
log.Fatal("Error reading file")
}
bwords := bytes.Fields(b)
var words []strin... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_WORD_SIZE 80
#define MIN_LENGTH 9
#define WORD_SIZE (MIN_LENGTH + 1)
void fatal(const char* message) {
fprintf(stderr, "%s\n", message);
exit(1);
}
void* xmalloc(size_t n) {
void* ptr = malloc(n);
if (ptr == NULL)
fatal("O... |
Rewrite this program in C while keeping its functionality equivalent to the Go version. | package main
import (
"fmt"
"rcu"
)
func main() {
var res []int
for n := 1; n < 1000; n++ {
digits := rcu.Digits(n, 10)
var all = true
for _, d := range digits {
if d == 0 || n%d != 0 {
all = false
break
}
}
... | #include <stdio.h>
int divisible(int n) {
int p = 1;
int c, d;
for (c=n; c; c /= 10) {
d = c % 10;
if (!d || n % d) return 0;
p *= d;
}
return n % p;
}
int main() {
int n, c=0;
for (n=1; n<1000; n++) {
if (divisible(n)) {
printf("%... |
Generate a C translation of this Go snippet without changing its computational steps. | package main
import "fmt"
func xor(a, b byte) byte {
return a&(^b) | b&(^a)
}
func ha(a, b byte) (s, c byte) {
return xor(a, b), a & b
}
func fa(a, b, c0 byte) (s, c1 byte) {
sa, ca := ha(a, c0)
s, cb := ha(sa, b)
c1 = ca | cb
return
}
func add4(a3, a2, a1, a0, b3, b2, b1, b0 byte) (v, s3, ... | #include <stdio.h>
typedef char pin_t;
#define IN const pin_t *
#define OUT pin_t *
#define PIN(X) pin_t _##X; pin_t *X = & _##X;
#define V(X) (*(X))
#define NOT(X) (~(X)&1)
#define XOR(X,Y) ((NOT(X)&(Y)) | ((X)&NOT(Y)))
void halfadder(IN a, IN b, OUT s, OUT c)
{
V(s) = XOR(V(a), V(b));
V(c) = V(a) & V(b);
}
... |
Please provide an equivalent version of this Go code in C. | package main
import "fmt"
func xor(a, b byte) byte {
return a&(^b) | b&(^a)
}
func ha(a, b byte) (s, c byte) {
return xor(a, b), a & b
}
func fa(a, b, c0 byte) (s, c1 byte) {
sa, ca := ha(a, c0)
s, cb := ha(sa, b)
c1 = ca | cb
return
}
func add4(a3, a2, a1, a0, b3, b2, b1, b0 byte) (v, s3, ... | #include <stdio.h>
typedef char pin_t;
#define IN const pin_t *
#define OUT pin_t *
#define PIN(X) pin_t _##X; pin_t *X = & _##X;
#define V(X) (*(X))
#define NOT(X) (~(X)&1)
#define XOR(X,Y) ((NOT(X)&(Y)) | ((X)&NOT(Y)))
void halfadder(IN a, IN b, OUT s, OUT c)
{
V(s) = XOR(V(a), V(b));
V(c) = V(a) & V(b);
}
... |
Port the provided Go code into C while preserving the original functionality. | package main
import (
"fmt"
"log"
)
func magicSquareOdd(n int) ([][]int, error) {
if n < 3 || n%2 == 0 {
return nil, fmt.Errorf("base must be odd and > 2")
}
value := 1
gridSize := n * n
c, r := n/2, 0
result := make([][]int, n)
for i := 0; i < n; i++ {
result[i] =... | #include<stdlib.h>
#include<ctype.h>
#include<stdio.h>
int** oddMagicSquare(int n) {
if (n < 3 || n % 2 == 0)
return NULL;
int value = 0;
int squareSize = n * n;
int c = n / 2, r = 0,i;
int** result = (int**)malloc(n*sizeof(int*));
for(i=0;i<n... |
Write the same code in C as shown below in Go. | package main
import (
"fmt"
"runtime"
"ex"
)
func main() {
f := func() {
pc, _, _, _ := runtime.Caller(0)
fmt.Println(runtime.FuncForPC(pc).Name(), "here!")
}
ex.X(f)
}
| #include <stdio.h>
#define sqr(x) ((x) * (x))
#define greet printf("Hello There!\n")
int twice(int x)
{
return 2 * x;
}
int main(void)
{
int x;
printf("This will demonstrate function and label scopes.\n");
printf("All output is happening through printf(), a function declared in the header stdio.h, which is exte... |
Port the provided Go code into C while preserving the original functionality. | package main
import (
"fmt"
"math/rand"
)
type symbols struct{ k, q, r, b, n rune }
var A = symbols{'K', 'Q', 'R', 'B', 'N'}
var W = symbols{'♔', '♕', '♖', '♗', '♘'}
var B = symbols{'♚', '♛', '♜', '♝', '♞'}
var krn = []string{
"nnrkr", "nrnkr", "nrknr", "nrkrn",
"rnnkr", "rnknr", "rnkrn",
"rknnr... | #include<stdlib.h>
#include<locale.h>
#include<wchar.h>
#include<stdio.h>
#include<time.h>
char rank[9];
int pos[8];
void swap(int i,int j){
int temp = pos[i];
pos[i] = pos[j];
pos[j] = temp;
}
void generateFirstRank(){
int kPos,qPos,bPos1,bPos2,rPos1,rPos2,nPos1,nPos2,i;
for(i=0;i<8;i++){
rank[i] = 'e... |
Preserve the algorithm and functionality while converting the code from Go to C. | package main
import "fmt"
func main() {
bf(10, `++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++
++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>>
>+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++.
<+++++++.--------.<<<<<+.<+++.---.`)
}
func bf(dLen int, is string) {
ds := make([]byt... | #include <stdio.h>
int main(){
int ptr=0, i=0, cell[7];
for( i=0; i<7; ++i) cell[i]=0;
ptr+= 1;
if(ptr>=7) perror("Program pointer overflow");
cell[ptr]+= 8;
while(cell[ptr])
{
ptr-= 1;
if(ptr<0) perror("Program pointer underflow");
cell[ptr]+= 9;
... |
Please provide an equivalent version of this Go code in C. | package main
import "fmt"
func main() {
bf(10, `++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++
++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>>
>+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++.
<+++++++.--------.<<<<<+.<+++.---.`)
}
func bf(dLen int, is string) {
ds := make([]byt... | #include <stdio.h>
int main(){
int ptr=0, i=0, cell[7];
for( i=0; i<7; ++i) cell[i]=0;
ptr+= 1;
if(ptr>=7) perror("Program pointer overflow");
cell[ptr]+= 8;
while(cell[ptr])
{
ptr-= 1;
if(ptr<0) perror("Program pointer underflow");
cell[ptr]+= 9;
... |
Ensure the translated C code behaves exactly like the original Go snippet. |
package main
import "fmt"
func MeaningOfLife() int {
return 42
}
func libMain() {
fmt.Println("The meaning of life is", MeaningOfLife())
}
| int meaning_of_life();
|
Keep all operations the same but rewrite the snippet in C. |
package main
import "fmt"
func MeaningOfLife() int {
return 42
}
func libMain() {
fmt.Println("The meaning of life is", MeaningOfLife())
}
| int meaning_of_life();
|
Rewrite the snippet below in C so it works the same as the original Go code. | package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(noise(3.14, 42, 7))
}
func noise(x, y, z float64) float64 {
X := int(math.Floor(x)) & 255
Y := int(math.Floor(y)) & 255
Z := int(math.Floor(z)) & 255
x -= math.Floor(x)
y -= math.Floor(y)
z -= math.Floor(z)
u := fa... | #include<stdlib.h>
#include<stdio.h>
#include<math.h>
int p[512];
double fade(double t) { return t * t * t * (t * (t * 6 - 15) + 10); }
double lerp(double t, double a, double b) { return a + t * (b - a); }
double grad(int hash, double x, double y, double z) {
int h = hash & 15;
doubl... |
Ensure the translated C code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"log"
"math"
"os"
"path/filepath"
)
func commatize(n int64) string {
s := fmt.Sprintf("%d", n)
if n < 0 {
s = s[1:]
}
le := len(s)
for i := le - 3; i >= 1; i -= 3 {
s = s[0:i] + "," + s[i:]
}
if n >= 0 {
return s
}... | #include<windows.h>
#include<string.h>
#include<stdio.h>
#define MAXORDER 25
int main(int argC, char* argV[])
{
char str[MAXORDER],commandString[1000],*startPath;
long int* fileSizeLog = (long int*)calloc(sizeof(long int),MAXORDER),max;
int i,j,len;
double scale;
FILE* fp;
if(argC==1)
printf("Usage : %s <fol... |
Write a version of this Go function in C with identical behavior. | package main
import (
"fmt"
"log"
"os"
"sort"
)
func main() {
f, err := os.Open(".")
if err != nil {
log.Fatal(err)
}
files, err := f.Readdirnames(0)
f.Close()
if err != nil {
log.Fatal(err)
}
sort.Strings(files)
for _, n := range files {
fmt.Println(n)
}
}
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
int cmpstr(const void *a, const void *b)
{
return strcmp(*(const char**)a, *(const char**)b);
}
int main(void)
{
DIR *basedir;
char path[PATH_MAX];
struct diren... |
Rewrite the snippet below in C so it works the same as the original Go code. | package main
import (
"errors"
"fmt"
"strings"
"sync"
)
var hdText = `Humpty Dumpty sat on a wall.
Humpty Dumpty had a great fall.
All the king's horses and all the king's men,
Couldn't put Humpty together again.`
var mgText = `Old Mother Goose,
When she wanted to wander,
Would ride through the air,
... | #include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
typedef struct rendezvous {
pthread_mutex_t lock;
pthread_cond_t cv_entering;
pthread_cond_t cv_accepting;
pthread_cond_t cv_done;
int (*accept_func)(void*);
int entering;
int accepting; ... |
Maintain the same structure and functionality when rewriting this code in C. | package main
import (
"fmt"
"rcu"
)
func main() {
var primes []int
candidates := []int{3, 33}
for i := 303; i <= 393; i += 10 {
candidates = append(candidates, i)
}
for i := 3003; i <= 3993; i += 10 {
candidates = append(candidates, i)
}
for _, cand := range candida... | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
int isprime( int p ) {
int i;
if(p==2) return 1;
if(!(p%2)) return 0;
for(i=3; i*i<=p; i+=2) {
if(!(p%i)) return 0;
}
return 1;
}
int main(void) {
int np = 1, d, i, n;
printf( "3 " );
for(d=1; d<6; d++) {
for(i=3... |
Rewrite this program in C while keeping its functionality equivalent to the Go version. | package main
import (
"fmt"
"rcu"
)
func main() {
var primes []int
candidates := []int{3, 33}
for i := 303; i <= 393; i += 10 {
candidates = append(candidates, i)
}
for i := 3003; i <= 3993; i += 10 {
candidates = append(candidates, i)
}
for _, cand := range candida... | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
int isprime( int p ) {
int i;
if(p==2) return 1;
if(!(p%2)) return 0;
for(i=3; i*i<=p; i+=2) {
if(!(p%i)) return 0;
}
return 1;
}
int main(void) {
int np = 1, d, i, n;
printf( "3 " );
for(d=1; d<6; d++) {
for(i=3... |
Keep all operations the same but rewrite the snippet in C. | package main
import (
"fmt"
"rcu"
)
func main() {
var primes []int
candidates := []int{3, 33}
for i := 303; i <= 393; i += 10 {
candidates = append(candidates, i)
}
for i := 3003; i <= 3993; i += 10 {
candidates = append(candidates, i)
}
for _, cand := range candida... | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
int isprime( int p ) {
int i;
if(p==2) return 1;
if(!(p%2)) return 0;
for(i=3; i*i<=p; i+=2) {
if(!(p%i)) return 0;
}
return 1;
}
int main(void) {
int np = 1, d, i, n;
printf( "3 " );
for(d=1; d<6; d++) {
for(i=3... |
Generate a C translation of this Go snippet without changing its computational steps. | package main
import "fmt"
const jobs = 12
type environment struct{ seq, cnt int }
var (
env [jobs]environment
seq, cnt *int
)
func hail() {
fmt.Printf("% 4d", *seq)
if *seq == 1 {
return
}
(*cnt)++
if *seq&1 != 0 {
*seq = 3*(*seq) + 1
} else {
*seq /= 2
... | #include <stdio.h>
#define JOBS 12
#define jobs(a) for (switch_to(a = 0); a < JOBS || !printf("\n"); switch_to(++a))
typedef struct { int seq, cnt; } env_t;
env_t env[JOBS] = {{0, 0}};
int *seq, *cnt;
void hail()
{
printf("% 4d", *seq);
if (*seq == 1) return;
++*cnt;
*seq = (*seq & 1) ? 3 * *seq + 1 : *seq / 2;
... |
Convert this Go snippet to C and keep its semantics consistent. | package main
import (
"bytes"
"encoding/hex"
"fmt"
"log"
"strings"
)
var testCases = []struct {
rune
string
}{
{'A', "41"},
{'ö', "C3 B6"},
{'Ж', "D0 96"},
{'€', "E2 82 AC"},
{'𝄞', "F0 9D 84 9E"},
}
func main() {
for _, tc := range testCases {
u :... | #include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
typedef struct {
char mask;
char lead;
uint32_t beg;
uint32_t end;
int bits_stored;
}utf_t;
utf_t * utf[] = {
[0] = &(utf_t){0b00111111, 0b10000000, 0, 0, 6 },
[1] = &(utf_t){0b01111111, 0b00000000, 0000, 0177, 7 ... |
Change the following Go code into C without altering its purpose. | package raster
import "math"
func ipart(x float64) float64 {
return math.Floor(x)
}
func round(x float64) float64 {
return ipart(x + .5)
}
func fpart(x float64) float64 {
return x - ipart(x)
}
func rfpart(x float64) float64 {
return 1 - fpart(x)
}
func (g *Grmap) AaLine(x1, y1, x2, y2 float64) {
... | void draw_line_antialias(
image img,
unsigned int x0, unsigned int y0,
unsigned int x1, unsigned int y1,
color_component r,
color_component g,
color_component b );
|
Generate a C translation of this Go snippet without changing its computational steps. | package main
import "C"
import "fmt"
import "unsafe"
func main() {
d := C.XOpenDisplay(nil)
f7, f6 := C.CString("F7"), C.CString("F6")
defer C.free(unsafe.Pointer(f7))
defer C.free(unsafe.Pointer(f6))
if d != nil {
C.XGrabKey(d, C.int(C.XKeysymToKeycode(d, C.XStringToKeysym(f7))),
... | #include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
int main()
{
Display *d;
XEvent event;
d = XOpenDisplay(NULL);
if ( d != NULL ) {
XGrabKey(d, XKeysymToKeycode(d, XStringToKeysym("F7")),
Mod1Mask,
DefaultRootWindow(d), True, GrabModeAsy... |
Port the provided Go code into C while preserving the original functionality. | package main
import "fmt"
func mcnugget(limit int) {
sv := make([]bool, limit+1)
for s := 0; s <= limit; s += 6 {
for n := s; n <= limit; n += 9 {
for t := n; t <= limit; t += 20 {
sv[t] = true
}
}
}
for i := limit; i >= 0; i-- {
if !sv[... | #include <stdio.h>
int
main() {
int max = 0, i = 0, sixes, nines, twenties;
loopstart: while (i < 100) {
for (sixes = 0; sixes*6 < i; sixes++) {
if (sixes*6 == i) {
i++;
goto loopstart;
}
for (nines = 0; nines*9 < i; nines++) {
... |
Change the programming language of this snippet from Go to C without modifying what it does. | package main
import (
"fmt"
"log"
"strings"
)
const dimensions int = 8
func setupMagicSquareData(d int) ([][]int, error) {
var output [][]int
if d < 4 || d%4 != 0 {
return [][]int{}, fmt.Errorf("Square dimension must be a positive number which is divisible by 4")
}
var bits uint = 0x9669
size := d * d
mu... | #include<stdlib.h>
#include<ctype.h>
#include<stdio.h>
int** doublyEvenMagicSquare(int n) {
if (n < 4 || n % 4 != 0)
return NULL;
int bits = 38505;
int size = n * n;
int mult = n / 4,i,r,c,bitPos;
int** result = (int**)malloc(n*sizeof(int*));
for(i=0;i<n;i++)
result[i] = (int*)malloc(n*sizeof(int));
fo... |
Change the following Go code into C without altering its purpose. | package main
import (
"fmt"
"math"
)
func main() {
var zero float64
var negZero, posInf, negInf, nan float64
negZero = zero * -1
posInf = 1 / zero
negInf = -1 / zero
nan = zero / zero
fmt.Println(negZero, posInf, negInf, nan)
fmt.Print... | #include <stdio.h>
int main()
{
double inf = 1/0.0;
double minus_inf = -1/0.0;
double minus_zero = -1/ inf ;
double nan = 0.0/0.0;
printf("positive infinity: %f\n",inf);
printf("negative infinity: %f\n",minus_inf);
printf("negative zero: %f\n",minus_zero);
printf("not a number: %f\n",n... |
Ensure the translated C code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"math"
)
func main() {
var zero float64
var negZero, posInf, negInf, nan float64
negZero = zero * -1
posInf = 1 / zero
negInf = -1 / zero
nan = zero / zero
fmt.Println(negZero, posInf, negInf, nan)
fmt.Print... | #include <stdio.h>
int main()
{
double inf = 1/0.0;
double minus_inf = -1/0.0;
double minus_zero = -1/ inf ;
double nan = 0.0/0.0;
printf("positive infinity: %f\n",inf);
printf("negative infinity: %f\n",minus_inf);
printf("negative zero: %f\n",minus_zero);
printf("not a number: %f\n",n... |
Convert this Go snippet to C and keep its semantics consistent. | package main
import (
"fmt"
"math"
)
const CONST = 0x2545F4914F6CDD1D
type XorshiftStar struct{ state uint64 }
func XorshiftStarNew(state uint64) *XorshiftStar { return &XorshiftStar{state} }
func (xor *XorshiftStar) seed(state uint64) { xor.state = state }
func (xor *XorshiftStar) nextInt() uint32 {
... | #include <math.h>
#include <stdint.h>
#include <stdio.h>
static uint64_t state;
static const uint64_t STATE_MAGIC = 0x2545F4914F6CDD1D;
void seed(uint64_t num) {
state = num;
}
uint32_t next_int() {
uint64_t x;
uint32_t answer;
x = state;
x = x ^ (x >> 12);
x = x ^ (x << 25);
x = x ^ (x ... |
Convert the following code from Go to C, ensuring the logic remains intact. | package main
import (
"fmt"
"strings"
"unicode"
)
func main() {
f := NewFourIsSeq()
fmt.Print("The lengths of the first 201 words are:")
for i := 1; i <= 201; i++ {
if i%25 == 1 {
fmt.Printf("\n%3d: ", i)
}
_, n := f.WordLen(i)
fmt.Printf(" %2d", n)
}
fmt.Println()
fmt.Println("Length of sentence ... | #include <ctype.h>
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <glib.h>
typedef uint64_t integer;
typedef struct number_names_tag {
const char* cardinal;
const char* ordinal;
} number_names;
const number_names small[] = {
{ "zero", "zeroth" }, { "one", "first"... |
Port the following code from Go to C with equivalent syntax and logic. | PACKAGE MAIN
IMPORT (
"FMT"
"TIME"
)
CONST PAGEWIDTH = 80
FUNC MAIN() {
PRINTCAL(1969)
}
FUNC PRINTCAL(YEAR INT) {
THISDATE := TIME.DATE(YEAR, 1, 1, 1, 1, 1, 1, TIME.UTC)
VAR (
DAYARR [12][7][6]INT
MONTH, LASTMONTH TIME.MONTH
WEEKINMONTH, DAYI... |
INT PUTCHAR(INT);
INT WIDTH = 80, YEAR = 1969;
INT COLS, LEAD, GAP;
CONST CHAR *WDAYS[] = { "SU", "MO", "TU", "WE", "TH", "FR", "SA" };
STRUCT MONTHS {
CONST CHAR *NAME;
INT DAYS, START_WDAY, AT;
} MONTHS[12] = {
{ "JANUARY", 31, 0, 0 },
{ "FEBRUARY", 28, 0, 0 },
{ "MARCH", 31, 0, ... |
Transform the following Go implementation into C, maintaining the same output and logic. | package main
import (
"fmt"
"log"
"math/big"
"strings"
)
type result struct {
name string
size int
start int
end int
}
func (r result) String() string {
return fmt.Sprintf("%-7s %2d %3d %3d", r.name, r.size, r.start, r.end)
}
func validate(diagram string) []string {
... | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
enum { MAX_ROWS=14, MAX_NAMES=20, NAME_SZ=80 };
char *Lines[MAX_ROWS] = {
" +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+",
" | ID |",
" +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+",
" |QR| ... |
Write the same code in C as shown below in Go. | package main
import (
"fmt"
"github.com/biogo/biogo/align"
ab "github.com/biogo/biogo/alphabet"
"github.com/biogo/biogo/feat"
"github.com/biogo/biogo/seq/linear"
)
func main() {
lc := ab.Must(ab.NewAlphabet("-abcdefghijklmnopqrstuvwxyz",
feat.Undefined, '-', 0, true))
... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct edit_s edit_t, *edit;
struct edit_s {
char c1, c2;
int n;
edit next;
};
void leven(char *a, char *b)
{
int i, j, la = strlen(a), lb = strlen(b);
edit *tbl = malloc(sizeof(edit) * (1 + la));
tbl[0] = calloc((1 + la) * (1 + lb), sizeof(edit... |
Change the programming language of this snippet from Go to C without modifying what it does. | package main
import (
"log"
"math/rand"
"testing"
"time"
"github.com/gonum/plot"
"github.com/gonum/plot/plotter"
"github.com/gonum/plot/plotutil"
"github.com/gonum/plot/vg"
)
func bubblesort(a []int) {
for itemCount := len(a) - 1; ; itemCount-- {
hasChanged := false
... | #ifndef _CSEQUENCE_H
#define _CSEQUENCE_H
#include <stdlib.h>
void setfillconst(double c);
void fillwithconst(double *v, int n);
void fillwithrrange(double *v, int n);
void shuffledrange(double *v, int n);
#endif
|
Generate a C translation of this Go snippet without changing its computational steps. | package main
import "fmt"
type node struct {
int
left, right *node
}
func leaves(t *node) chan int {
ch := make(chan int)
var f func(*node)
f = func(n *node) {
if n == nil {
return
}
if n.left == nil && n.right == nil {
ch <- n.int
... | #include <stdio.h>
#include <stdlib.h>
#include <ucontext.h>
typedef struct {
ucontext_t caller, callee;
char stack[8192];
void *in, *out;
} co_t;
co_t * co_new(void(*f)(), void *data)
{
co_t * c = malloc(sizeof(*c));
getcontext(&c->callee);
c->in = data;
c->callee.uc_stack.ss_sp = c->stack;
c->callee.uc_sta... |
Produce a functionally identical C code for the snippet given in Go. | package main
import (
"flag"
"fmt"
)
func main() {
b := flag.Bool("b", false, "just a boolean")
s := flag.String("s", "", "any ol' string")
n := flag.Int("n", 0, "your lucky number")
flag.Parse()
fmt.Println("b:", *b)
fmt.Println("s:", *s)
fmt.Println("n:", *n)
}
| #include <stdio.h>
int main(int argc, char **argv){
int i;
const char *commands[]={"-c", "-p", "-t", "-d", "-a", NULL};
enum {CREATE,PRINT,TITLE,DATE,AUTH};
if (argc<2) {
usage: printf ("Usage: %s [commands]\n"
"-c Create new entry.\n"
"-p Print the latest entry.\n"
... |
Can you help me rewrite this code in C instead of Go, keeping it the same logically? | package main
import (
"flag"
"fmt"
)
func main() {
b := flag.Bool("b", false, "just a boolean")
s := flag.String("s", "", "any ol' string")
n := flag.Int("n", 0, "your lucky number")
flag.Parse()
fmt.Println("b:", *b)
fmt.Println("s:", *s)
fmt.Println("n:", *n)
}
| #include <stdio.h>
int main(int argc, char **argv){
int i;
const char *commands[]={"-c", "-p", "-t", "-d", "-a", NULL};
enum {CREATE,PRINT,TITLE,DATE,AUTH};
if (argc<2) {
usage: printf ("Usage: %s [commands]\n"
"-c Create new entry.\n"
"-p Print the latest entry.\n"
... |
Produce a functionally identical C code for the snippet given in Go. | package main
import (
"fmt"
"strconv"
"strings"
)
func a(n int) {
s, _ := strconv.Atoi(strings.Repeat("1", n) + "3")
t := s * s
fmt.Printf("%d %d\n", s, t)
}
func main() {
for n := 0; n <= 7; n++ {
a(n)
}
}
| #include <stdio.h>
#include <stdint.h>
uint64_t ones_plus_three(uint64_t ones) {
uint64_t r = 0;
while (ones--) r = r*10 + 1;
return r*10 + 3;
}
int main() {
uint64_t n;
for (n=0; n<8; n++) {
uint64_t x = ones_plus_three(n);
printf("%8lu^2 = %15lu\n", x, x*x);
}
return 0;
}... |
Please provide an equivalent version of this Go code in C. | package main
import (
"fmt"
"strconv"
"strings"
)
func a(n int) {
s, _ := strconv.Atoi(strings.Repeat("1", n) + "3")
t := s * s
fmt.Printf("%d %d\n", s, t)
}
func main() {
for n := 0; n <= 7; n++ {
a(n)
}
}
| #include <stdio.h>
#include <stdint.h>
uint64_t ones_plus_three(uint64_t ones) {
uint64_t r = 0;
while (ones--) r = r*10 + 1;
return r*10 + 3;
}
int main() {
uint64_t n;
for (n=0; n<8; n++) {
uint64_t x = ones_plus_three(n);
printf("%8lu^2 = %15lu\n", x, x*x);
}
return 0;
}... |
Convert the following code from Go to C, ensuring the logic remains intact. | package main
import (
"github.com/micmonay/keybd_event"
"log"
"runtime"
"time"
)
func main() {
kb, err := keybd_event.NewKeyBonding()
if err != nil {
log.Fatal(err)
}
if runtime.GOOS == "linux" {
time.Sleep(2 * time.Second)
}
kb.SetKeys(keybd_event.V... | #include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main(int argc, char *argv[])
{
Display *dpy;
Window win;
GC gc;
int scr;
Atom WM_DELETE_WINDOW;
XEvent ev;
XEvent ev2;
KeySym keysym;
int loop;
dpy = XOpenDisplay(NULL);
if (dpy == NULL) {
fputs("Canno... |
Port the following code from Go to C with equivalent syntax and logic. | package main
import "fmt"
const (
empty = iota
black
white
)
const (
bqueen = 'B'
wqueen = 'W'
bbullet = '•'
wbullet = '◦'
)
type position struct{ i, j int }
func iabs(i int) int {
if i < 0 {
return -i
}
return i
}
func place(m, n int, pBlackQueens, pWhiteQueens *... | #include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
enum Piece {
Empty,
Black,
White,
};
typedef struct Position_t {
int x, y;
} Position;
struct Node_t {
Position pos;
struct Node_t *next;
};
void releaseNode(struct Node_t *head) {
if (head == NULL) return;
... |
Write a version of this Go function in C with identical behavior. | package main
import "fmt"
func main() {
for {
fmt.Printf("SPAM\n")
}
}
| while(1) puts("SPAM");
|
Write a version of this Go function in C with identical behavior. | package main
import "fmt"
type person struct{
name string
age int
}
func copy(p person) person {
return person{p.name, p.age}
}
func main() {
p := person{"Dave", 40}
fmt.Println(p)
q := copy(p)
fmt.Println(q)
}
|
#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(!!(COND))*2-1]
#define COMPILE_TIME_ASSERT3(X,L) STATIC_ASSERT(X,static_assertion_at_line_##L)
#define COMPILE_TIME_ASSERT2(X,L) COMPILE_TIME_ASSERT3(X,L)
#define COMPILE_TIME_ASSERT(X) COMPILE_TIME_ASSERT2(X,__LINE__)
COMPILE_TIME_ASSERT(sizeof... |
Transform the following Go implementation into C, maintaining the same output and logic. | package main
import (
"fmt"
"rcu"
"strconv"
)
func equalSets(s1, s2 map[rune]bool) bool {
if len(s1) != len(s2) {
return false
}
for k, _ := range s1 {
_, ok := s2[k]
if !ok {
return false
}
}
return true
}
func main() {
const limit = 10... | #include <stdio.h>
#define LIMIT 100000
int digitset(int num, int base) {
int set;
for (set = 0; num; num /= base)
set |= 1 << num % base;
return set;
}
int main() {
int i, c = 0;
for (i = 0; i < LIMIT; i++)
if (digitset(i,10) == digitset(i,16))
printf("%6d%c", i, ++c%1... |
Change the programming language of this snippet from Go to C without modifying what it does. | package main
import "fmt"
func largestPrimeFactor(n uint64) uint64 {
if n < 2 {
return 1
}
inc := [8]uint64{4, 2, 4, 2, 4, 6, 2, 6}
max := uint64(1)
for n%2 == 0 {
max = 2
n /= 2
}
for n%3 == 0 {
max = 3
n /= 3
}
for n%5 == 0 {
max = ... | #include <stdio.h>
#include <stdlib.h>
int isprime( long int n ) {
int i=3;
if(!(n%2)) return 0;
while( i*i < n ) {
if(!(n%i)) return 0;
i+=2;
}
return 1;
}
int main(void) {
long int n=600851475143, j=3;
while(!isprime(n)) {
if(!(n%j)) n/=j;
j+=2;
}
... |
Translate this program into C but keep the logic exactly as in Go. | package main
import "fmt"
func largestProperDivisor(n int) int {
for i := 2; i*i <= n; i++ {
if n%i == 0 {
return n / i
}
}
return 1
}
func main() {
fmt.Println("The largest proper divisors for numbers in the interval [1, 100] are:")
fmt.Print(" 1 ")
for n := 2; n... | #include <stdio.h>
unsigned int lpd(unsigned int n) {
if (n<=1) return 1;
int i;
for (i=n-1; i>0; i--)
if (n%i == 0) return i;
}
int main() {
int i;
for (i=1; i<=100; i++) {
printf("%3d", lpd(i));
if (i % 10 == 0) printf("\n");
}
return 0;
}
|
Change the programming language of this snippet from Go to C without modifying what it does. | package main
import (
"fmt"
"strconv"
)
func toWord(w int64) string { return fmt.Sprintf("W%05d", w) }
func fromWord(ws string) int64 {
var u, _ = strconv.ParseUint(ws[1:], 10, 64)
return int64(u)
}
func main() {
fmt.Println("Starting figures:")
lat := 28.3852
lon := -81.5638
fmt.Pri... | #include <stdio.h>
#include <stdlib.h>
typedef long long int64;
void to_word(char *ws, int64 w) {
sprintf(ws, "W%05lld", w);
}
int64 from_word(char *ws) {
return atoi(++ws);
}
int main() {
double lat, lon;
int64 latlon, ilat, ilon, w1, w2, w3;
char w1s[7], w2s[7], w3s[7];
printf("Starting f... |
Rewrite this program in C while keeping its functionality equivalent to the Go version. | package main
import (
"bytes"
"fmt"
)
type symbolTable string
func (symbols symbolTable) encode(s string) []byte {
seq := make([]byte, len(s))
pad := []byte(symbols)
for i, c := range []byte(s) {
x := bytes.IndexByte(pad, c)
seq[i] = byte(x)
copy(pad[1:], pad[:x])
pad[0] = c
}
return seq
}
func (symb... | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX_SIZE 100
int move_to_front(char *str,char c)
{
char *q,*p;
int shift=0;
p=(char *)malloc(strlen(str)+1);
strcpy(p,str);
q=strchr(p,c);
shift=q-p;
strncpy(str+1,p,shift);
str[0]=c;
free(p);
return shif... |
Please provide an equivalent version of this Go code in C. | package main
import (
"log"
"github.com/jtblin/go-ldap-client"
)
func main() {
client := &ldap.LDAPClient{
Base: "dc=example,dc=com",
Host: "ldap.example.com",
Port: 389,
GroupFilter: "(memberUid=%s)",
}
defer client.Close()
err := client.Co... | #include <ldap.h>
char *name, *password;
...
LDAP *ld = ldap_init("ldap.somewhere.com", 389);
ldap_simple_bind_s(ld, name, password);
LDAPMessage **result;
ldap_search_s(ld, "dc=somewhere,dc=com", LDAP_SCOPE_SUBTREE,
"(&(objectclass=person)(|(cn=joe*)(cn=shmoe*)))",
NULL,
0,
result);
ldap_msgfree(*resul... |
Please provide an equivalent version of this Go code in C. | <package main
import (
"fmt"
"gonum.org/v1/gonum/mat"
"log"
)
func matPrint(m mat.Matrix) {
fa := mat.Formatted(m, mat.Prefix(""), mat.Squeeze())
fmt.Printf("%13.10f\n", fa)
}
func main() {
var svd mat.SVD
a := mat.NewDense(2, 2, []float64{3, 0, 4, 5})
ok := svd.Factorize(a, mat.SVDFu... | #include <stdio.h>
#include <gsl/gsl_linalg.h>
void gsl_matrix_print(const gsl_matrix *M) {
int rows = M->size1;
int cols = M->size2;
for (int i = 0; i < rows; i++) {
printf("|");
for (int j = 0; j < cols; j++) {
printf("% 12.10f ", gsl_matrix_get(M, i, j));
}
p... |
Translate the given Go code snippet into C without altering its behavior. | package main
import (
"fmt"
"rcu"
)
func main() {
fmt.Println("Cumulative sums of the first 50 cubes:")
sum := 0
for n := 0; n < 50; n++ {
sum += n * n * n
fmt.Printf("%9s ", rcu.Commatize(sum))
if n%10 == 9 {
fmt.Println()
}
}
fmt.Println()
| #include <stdio.h>
int main() {
for (int i = 0, sum = 0; i < 50; ++i) {
sum += i * i * i;
printf("%7d%c", sum, (i + 1) % 5 == 0 ? '\n' : ' ');
}
return 0;
}
|
Produce a functionally identical C code for the snippet given in Go. | package main
import (
"fmt"
"io"
"log"
"os"
"sync/atomic"
"syscall"
)
const (
inputFifo = "/tmp/in.fifo"
outputFifo = "/tmp/out.fifo"
readsize = 64 << 10
)
func openFifo(path string, oflag int) (f *os.File, err error) {
err = syscall.... | #include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <pthread.h>
#define WILL_BLOCK_EVERYTHING 0
#if WILL_BLOCK_EVERYTHING
#include <poll.h>
#endif
size_t tally = 0;
void* write_loop(void *a)
{
int fd;
char buf[32];
while (1) {
#if WILL_BLOCK_EVERYTHING
... |
Translate this program into C but keep the logic exactly as in Go. | package main
import (
"fmt"
"math"
"math/big"
"reflect"
"strings"
"unsafe"
)
func Float64IsInt(f float64) bool {
_, frac := math.Modf(f)
return frac == 0
}
func Float32IsInt(f float32) bool {
return Float64IsInt(float64(f))
}
func Complex128IsInt(c complex128) bool {
return imag(c) == 0 && Float6... | #include <stdio.h>
#include <complex.h>
#include <math.h>
#define FMTSPEC(arg) _Generic((arg), \
float: "%f", double: "%f", \
long double: "%Lf", unsigned int: "%u", \
unsigned long: "%lu", unsigned long long: "%llu", \
int: "%d", long: "%ld", long long: "%lld", \
default: "(invalid type (%p)")
#... |
Transform the following Go implementation into C, maintaining the same output and logic. | package main
import (
"log"
"os"
"os/exec"
)
func main() {
cmd := exec.Command("ls", "-l")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
}
| #include <stdlib.h>
int main()
{
system("ls");
return 0;
}
|
Port the provided Go code into C while preserving the original functionality. | package main
import (
"fmt"
"math"
)
type vector [3]float64
type matrix [3]vector
func norm(v vector) float64 {
return math.Sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
}
func normalize(v vector) vector {
length := norm(v)
return vector{v[0] / length, v[1] / length, v[2] / length}
}
func dotProduct(... | #include <stdio.h>
#include <math.h>
typedef struct {
double x, y, z;
} vector;
typedef struct {
vector i, j, k;
} matrix;
double norm(vector v) {
return sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}
vector normalize(vector v){
double length = norm(v);
vector n = {v.x / length, v.y / length, v.z / length... |
Write the same code in C as shown below in Go. | package main
import (
"fmt"
"github.com/lestrrat-go/libxml2"
"github.com/lestrrat-go/libxml2/xsd"
"io/ioutil"
"log"
"os"
)
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
func main() {
xsdfile := "shiporder.xsd"
f, err := os.Open(xsdfile)
check(err)
... | #include <libxml/xmlschemastypes.h>
int main(int argC, char** argV)
{
if (argC <= 2) {
printf("Usage: %s <XML Document Name> <XSD Document Name>\n", argV[0]);
return 0;
}
xmlDocPtr doc;
xmlSchemaPtr schema = NULL;
xmlSchemaParserCtxtPtr ctxt;
char *XMLFileName = argV[1];
char *XSDFileName = argV[2];
int ... |
Write a version of this Go function in C with identical behavior. | package main
import (
"fmt"
"sort"
)
type Node struct {
val int
back *Node
}
func lis (n []int) (result []int) {
var pileTops []*Node
for _, x := range n {
j := sort.Search(len(pileTops), func (i int) bool { return pileTops[i].val >= x })
node := &Node{ x, nil }
if j != 0 { node.back =... | #include <stdio.h>
#include <stdlib.h>
struct node {
int val, len;
struct node *next;
};
void lis(int *v, int len)
{
int i;
struct node *p, *n = calloc(len, sizeof *n);
for (i = 0; i < len; i++)
n[i].val = v[i];
for (i = len; i--; ) {
for (p = n + i; p++ < n + len; ) {
if (p->val > n[i].val && p->len... |
Translate the given Go code snippet into C without altering its behavior. | package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"os"
)
type vector [3]float64
func (v *vector) normalize() {
invLen := 1 / math.Sqrt(dot(v, v))
v[0] *= invLen
v[1] *= invLen
v[2] *= invLen
}
func dot(x, y *vector) float64 {
return x[0]*y[0] + x[1]*y[1... | #include <stdio.h>
#include <math.h>
#include <unistd.h>
const char *shades = ".:!*oe&#%@";
double light[3] = { -50, 0, 50 };
void normalize(double * v)
{
double len = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
v[0] /= len; v[1] /= len; v[2] /= len;
}
double dot(double *x, double *y)
{
double d = x[0]*y[0] + x[1]*y... |
Please provide an equivalent version of this Go code in C. | package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"os"
)
type vector [3]float64
func (v *vector) normalize() {
invLen := 1 / math.Sqrt(dot(v, v))
v[0] *= invLen
v[1] *= invLen
v[2] *= invLen
}
func dot(x, y *vector) float64 {
return x[0]*y[0] + x[1]*y[1... | #include <stdio.h>
#include <math.h>
#include <unistd.h>
const char *shades = ".:!*oe&#%@";
double light[3] = { -50, 0, 50 };
void normalize(double * v)
{
double len = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
v[0] /= len; v[1] /= len; v[2] /= len;
}
double dot(double *x, double *y)
{
double d = x[0]*y[0] + x[1]*y... |
Rewrite this program in C while keeping its functionality equivalent to the Go version. | package main
import (
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"math"
"os"
)
func hough(im image.Image, ntx, mry int) draw.Image {
nimx := im.Bounds().Max.X
mimy := im.Bounds().Max.Y
him := image.NewGray(image.Rect(0, 0, ntx, mry))
draw.Draw(him, him.Bounds(), ... | #include "SL_Generated.h"
#include "CImg.h"
using namespace cimg_library;
int main( int argc, char** argv )
{
string fileName = "Pentagon.bmp";
if(argc > 1) fileName = argv[1];
int thetaAxisSize = 640; if(argc > 2) thetaAxisSize = atoi(argv[2]);
int rAxisSize = 480; if(argc > 3) rAxisSize = atoi(argv[... |
Change the following Go code into C without altering its purpose. | package main
import (
"fmt"
"math"
)
type ifctn func(float64) float64
func simpson38(f ifctn, a, b float64, n int) float64 {
h := (b - a) / float64(n)
h1 := h / 3
sum := f(a) + f(b)
for j := 3*n - 1; j > 0; j-- {
if j%3 == 0 {
sum += 2 * f(a+h1*float64(j))
... | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
typedef double (* Ifctn)( double t);
double Simpson3_8( Ifctn f, double a, double b, int N)
{
int j;
double l1;
double h = (b-a)/N;
double h1 = h/3.0;
double sum = f(a) + f(b);
for... |
Ensure the translated C code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"math"
)
type ifctn func(float64) float64
func simpson38(f ifctn, a, b float64, n int) float64 {
h := (b - a) / float64(n)
h1 := h / 3
sum := f(a) + f(b)
for j := 3*n - 1; j > 0; j-- {
if j%3 == 0 {
sum += 2 * f(a+h1*float64(j))
... | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
typedef double (* Ifctn)( double t);
double Simpson3_8( Ifctn f, double a, double b, int N)
{
int j;
double l1;
double h = (b-a)/N;
double h1 = h/3.0;
double sum = f(a) + f(b);
for... |
Convert this Go block to C, preserving its control flow and logic. | package main
import (
"fmt"
"strings"
)
var data = `
FILE FILE DEPENDENCIES
==== =================
top1 des1 ip1 ip2
top2 des1 ip2 ip3
ip1 extra1 ip1a ipcommon
ip2 ip2a ip2b ip2c ipcommon
des1 des1a des1b des1c
des1a des1a1 des1a2
des1c des1c1 extra1`
func main() {
g, dep, err ... | char input[] = "top1 des1 ip1 ip2\n"
"top2 des1 ip2 ip3\n"
"ip1 extra1 ip1a ipcommon\n"
"ip2 ip2a ip2b ip2c ipcommon\n"
"des1 des1a des1b des1c\n"
"des1a des1a1 des1a2\n"
"des1c des1c1 extra1\n";
...
int find_name(item base, int len, const char *name)
{
int i;
for (i = 0; i < len; i+... |
Rewrite the snippet below in C so it works the same as the original Go code. | package main
import (
"fmt"
"strings"
)
var data = `
FILE FILE DEPENDENCIES
==== =================
top1 des1 ip1 ip2
top2 des1 ip2 ip3
ip1 extra1 ip1a ipcommon
ip2 ip2a ip2b ip2c ipcommon
des1 des1a des1b des1c
des1a des1a1 des1a2
des1c des1c1 extra1`
func main() {
g, dep, err ... | char input[] = "top1 des1 ip1 ip2\n"
"top2 des1 ip2 ip3\n"
"ip1 extra1 ip1a ipcommon\n"
"ip2 ip2a ip2b ip2c ipcommon\n"
"des1 des1a des1b des1c\n"
"des1a des1a1 des1a2\n"
"des1c des1c1 extra1\n";
...
int find_name(item base, int len, const char *name)
{
int i;
for (i = 0; i < len; i+... |
Rewrite the snippet below in C so it works the same as the original Go code. | package expand
type Expander interface {
Expand() []string
}
type Text string
func (t Text) Expand() []string { return []string{string(t)} }
type Alternation []Expander
func (alt Alternation) Expand() []string {
var out []string
for _, e := range alt {
out = append(out, e.Expand()...)
}
return out
}
... | #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFER_SIZE 128
typedef unsigned char character;
typedef character *string;
typedef struct node_t node;
struct node_t {
enum tag_t {
NODE_LEAF,
NODE_TREE,
NODE_SEQ,
} tag;
union {
stri... |
Generate a C translation of this Go snippet without changing its computational steps. | import (
"image"
"image/gif"
"io/ioutil"
"strings"
"unicode"
)
func f() (int, float64) { return 0, 0 }
func g(int, float64) int { return 0 }
func h(string, ...int) {}
|
f();
g(1, 2, 3);
int op_arg();
int main()
{
op_arg(1);
op_arg(1, 2);
op_arg(1, 2, 3);
return 0;
}
int op_arg(int a, int b)
{
printf("%d %d %d\n", a, b, (&b)[1]);
return a;
}
void h(int a, ...)
{
va_list ap;
va_start(ap);
...
}
h(1, 2, 3, 4, "abcd", (void*)0);
struct v_args {
int arg1;
int a... |
Rewrite this program in C while keeping its functionality equivalent to the Go version. | import (
"image"
"image/gif"
"io/ioutil"
"strings"
"unicode"
)
func f() (int, float64) { return 0, 0 }
func g(int, float64) int { return 0 }
func h(string, ...int) {}
|
f();
g(1, 2, 3);
int op_arg();
int main()
{
op_arg(1);
op_arg(1, 2);
op_arg(1, 2, 3);
return 0;
}
int op_arg(int a, int b)
{
printf("%d %d %d\n", a, b, (&b)[1]);
return a;
}
void h(int a, ...)
{
va_list ap;
va_start(ap);
...
}
h(1, 2, 3, 4, "abcd", (void*)0);
struct v_args {
int arg1;
int a... |
Translate this program into C but keep the logic exactly as in Go. | import (
"image"
"image/gif"
"io/ioutil"
"strings"
"unicode"
)
func f() (int, float64) { return 0, 0 }
func g(int, float64) int { return 0 }
func h(string, ...int) {}
|
f();
g(1, 2, 3);
int op_arg();
int main()
{
op_arg(1);
op_arg(1, 2);
op_arg(1, 2, 3);
return 0;
}
int op_arg(int a, int b)
{
printf("%d %d %d\n", a, b, (&b)[1]);
return a;
}
void h(int a, ...)
{
va_list ap;
va_start(ap);
...
}
h(1, 2, 3, 4, "abcd", (void*)0);
struct v_args {
int arg1;
int a... |
Write the same code in C as shown below in Go. | package main
import "fmt"
const max = 12
var (
super []byte
pos int
cnt [max]int
)
func factSum(n int) int {
s := 0
for x, f := 0, 1; x < n; {
x++
f *= x
s += f
}
return s
}
func r(n int) bool {
if n == 0 {
return false
}
c := super[pos-n... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 12
char *super = 0;
int pos, cnt[MAX];
int fact_sum(int n)
{
int s, x, f;
for (s = 0, x = 0, f = 1; x < n; f *= ++x, s += f);
return s;
}
int r(int n)
{
if (!n) return 0;
char c = super[pos - n];
if (!--cnt[n]) {
cnt[n] = n;
if (!r(n-... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.