kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Hilbert curve
Go: package main

import "github.com/fogleman/gg"

var points []gg.Point

const width = 64

func hilbert(x, y, lg, i1, i2 int) {
    if lg == 1 {
        px := float64(width-x) * 10
        py := float64(width-y) * 10
        points = append(points, gg.Point{px, py})
        return
    }
    lg >>= 1
    hilbert(x+i1*lg, y+i1*lg, lg, i1, 1-i2)
    hilbert(x+i2*lg, y+(1-i2)*lg, lg, i1, i2)
    hilbert(x+(1-i1)*lg, y+(1-i1)*lg, lg, i1, i2)
    hilbert(x+(1-i2)*lg, y+i2*lg, lg, 1-i1, i2)
}

func main() {
    hilbert(0, 0, width, 0, 0)
    dc := gg.NewContext(650, 650)
    dc.SetRGB(0, 0, 0) 
    dc.Clear()
    for _, p := range points {
        dc.LineTo(p.X, p.Y)
    }
    dc.SetHexColor("#90EE90") 
    dc.SetLineWidth(1)
    dc.Stroke()
    dc.SavePNG("hilbert.png")
}

Python: iterations = 7
stroke_len = 600
angle_deg = 90
axiom = 'L'
sentence = axiom
rules = {
    'L': '+RF-LFL-FR+',
    'R': '-LF+RFR+FL-',
}

def setup():
    size(700, 700)
    global xo, yo
    xo, yo = 50, height - 50
    strokeWeight(1)
    noFill()
    generate(iterations)

def draw():
    background(0)
    translate(xo, yo)
    plot(radians(angle_deg))

def generate(n):
    global stroke_len, sentence
    for _ in range(n):
        stroke_len *= 0.5
        next_sentence = ''
        for c in sentence:
            next_sentence += rules.get(c, c)
        sentence = next_sentence

def plot(angle):
    for c in sentence:
        if c == 'F':
            stroke(255)
            line(0, 0, 0, -stroke_len)
            translate(0, -stroke_len)
        elif c == '+':
            rotate(angle)
        elif c == '-':
            rotate(-angle)

def keyPressed():
    global angle_deg, xo, yo, stroke_len
    if key == '-':
        angle_deg -= 5
        print(angle_deg)
    if str(key) in "=+":
        angle_deg += 5
        print(angle_deg)
    if key == 'a':
        stroke_len *= 2
    if key == 'z':
        stroke_len /= 2
    if keyCode == LEFT:
        xo -= 50
    if keyCode == RIGHT:
        xo += 50
    if keyCode == UP:
        yo -= 50
    if keyCode == DOWN:
        yo += 50
Task: Hilbert curve
Go: package main

import "github.com/fogleman/gg"

var points []gg.Point

const width = 64

func hilbert(x, y, lg, i1, i2 int) {
    if lg == 1 {
        px := float64(width-x) * 10
        py := float64(width-y) * 10
        points = append(points, gg.Point{px, py})
        return
    }
    lg >>= 1
    hilbert(x+i1*lg, y+i1*lg, lg, i1, 1-i2)
    hilbert(x+i2*lg, y+(1-i2)*lg, lg, i1, i2)
    hilbert(x+(1-i1)*lg, y+(1-i1)*lg, lg, i1, i2)
    hilbert(x+(1-i2)*lg, y+i2*lg, lg, 1-i1, i2)
}

func main() {
    hilbert(0, 0, width, 0, 0)
    dc := gg.NewContext(650, 650)
    dc.SetRGB(0, 0, 0) 
    dc.Clear()
    for _, p := range points {
        dc.LineTo(p.X, p.Y)
    }
    dc.SetHexColor("#90EE90") 
    dc.SetLineWidth(1)
    dc.Stroke()
    dc.SavePNG("hilbert.png")
}

VB: option explicit


const pi180= 0.01745329251994329576923690768489 
const pi=3.1415926535897932384626433832795 
class turtle
   
   dim fso
   dim fn
   dim svg
   
   dim iang  
   dim ori   
   dim incr
   dim pdown
   dim clr
   dim x
   dim y

   public property let orient(n):ori = n*pi180 :end property
   public property let iangle(n):iang= n*pi180 :end property
   public sub pd() : pdown=true: end sub 
   public sub pu()  :pdown=FALSE :end sub 
   
   public sub rt(i)  
     ori=ori - i*iang:
     if ori<0 then ori = ori+pi*2
   end sub 
   public sub lt(i):  
     ori=(ori + i*iang) 
     if ori>(pi*2) then ori=ori-pi*2
   end sub
   
   public sub bw(l)
      x= x+ cos(ori+pi)*l*incr
      y= y+ sin(ori+pi)*l*incr
   end sub 
   
   public sub fw(l)
      dim x1,y1 
      x1=x + cos(ori)*l*incr
      y1=y + sin(ori)*l*incr
      if pdown then line x,y,x1,y1
      x=x1:y=y1
   end sub
   
   Private Sub Class_Initialize() 
      setlocale "us"    
      initsvg
      pdown=true
   end sub
   
   Private Sub Class_Terminate()   
      disply
   end sub
   
   private sub line (x,y,x1,y1)
      svg.WriteLine "<line x1=""" & x & """ y1= """& y & """ x2=""" & x1& """ y2=""" & y1 & """/>"
   end sub 

   private sub disply()
       dim shell
       svg.WriteLine "</svg></body></html>"
       svg.close
       Set shell = CreateObject("Shell.Application") 
       shell.ShellExecute fn,1,False
   end sub 

   private sub initsvg()
     dim scriptpath
     Set fso = CreateObject ("Scripting.Filesystemobject")
     ScriptPath= Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\"))
     fn=Scriptpath & "SIERP.HTML"
     Set svg = fso.CreateTextFile(fn,True)
     if SVG IS nothing then wscript.echo "Can
     svg.WriteLine "<!DOCTYPE html>" &vbcrlf & "<html>" &vbcrlf & "<head>"
     svg.writeline "<style>" & vbcrlf & "line {stroke:rgb(255,0,0);stroke-width:.5}" &vbcrlf &"</style>"
     svg.writeline "</head>"&vbcrlf & "<body>"
     svg.WriteLine "<svg xmlns=""http://www.w3.org/2000/svg"" width=""800"" height=""800"" viewBox=""0 0 800 800"">" 
   end sub 
end class

sub hilb (n,a)
if n=0 then exit sub
x.rt a
hilb n-1,-a: x.fw 1:x.lt a: Hilb n - 1,a 
x.fw 1
hilb n-1,a : x.lt a: x.fw 1: Hilb n - 1,-a 
x.rt a
end sub

 
dim x
set x=new turtle
x.iangle=90
x.orient=0
x.incr=5
x.x=100:x.y=700

hilb 7,1
set x=nothing
Task: Subset sum problem
C: #include <stdio.h>
#include <stdlib.h>

typedef struct {
    char *word;
    int weight;
} item_t;

item_t items[] = {
    {"alliance",     -624},
    {"archbishop",   -915},
    {"balm",          397},
    {"bonnet",        452},
    {"brute",         870},
    {"centipede",    -658},
    {"cobol",         362},
    {"covariate",     590},
    {"departure",     952},
    {"deploy",         44},
    {"diophantine",   645},
    {"efferent",       54},
    {"elysee",       -326},
    {"eradicate",     376},
    {"escritoire",    856},
    {"exorcism",     -983},
    {"fiat",          170},
    {"filmy",        -874},
    {"flatworm",      503},
    {"gestapo",       915},
    {"infra",        -847},
    {"isis",         -982},
    {"lindholm",      999},
    {"markham",       475},
    {"mincemeat",    -880},
    {"moresby",       756},
    {"mycenae",       183},
    {"plugging",     -266},
    {"smokescreen",   423},
    {"speakeasy",    -745},
    {"vein",          813},
};

int n = sizeof (items) / sizeof (item_t);
int *set;

void subsum (int i, int weight) {
    int j;
    if (i && !weight) {
        for (j = 0; j < i; j++) {
            item_t item = items[set[j]];
            printf("%s%s", j ? " " : "", items[set[j]].word);
        }
        printf("\n");
    }
    for (j = i ? set[i - 1] + 1: 0; j < n; j++) {
        set[i] = j;
        subsum(i + 1, weight + items[j].weight);
    }
}

int main () {
    set = malloc(n * sizeof (int));
    subsum(0, 0);
    return 0;
}

Go: package main

import "fmt"

type ww struct {
    word   string
    weight int
}

var input = []*ww{
    {"alliance", -624},
    {"archbishop", -915},
    {"balm", 397},
    {"bonnet", 452},
    {"brute", 870},
    {"centipede", -658},
    {"cobol", 362},
    {"covariate", 590},
    {"departure", 952},
    {"deploy", 44},
    {"diophantine", 645},
    {"efferent", 54},
    {"elysee", -326},
    {"eradicate", 376},
    {"escritoire", 856},
    {"exorcism", -983},
    {"fiat", 170},
    {"filmy", -874},
    {"flatworm", 503},
    {"gestapo", 915},
    {"infra", -847},
    {"isis", -982},
    {"lindholm", 999},
    {"markham", 475},
    {"mincemeat", -880},
    {"moresby", 756},
    {"mycenae", 183},
    {"plugging", -266},
    {"smokescreen", 423},
    {"speakeasy", -745},
    {"vein", 813},
}

type sss struct {
    subset []*ww
    sum    int
}

func main() {
    ps := []sss{{nil, 0}}
    for _, i := range input {
        pl := len(ps)
        for j := 0; j < pl; j++ {
            subset := append([]*ww{i}, ps[j].subset...)
            sum := i.weight + ps[j].sum
            if sum == 0 {
                fmt.Println("this subset sums to 0:")
                for _, i := range subset {
                    fmt.Println(*i)
                }
                return
            }
            ps = append(ps, sss{subset, sum})
        }
    }
    fmt.Println("no subset sums to 0")
}
Task: Subset sum problem
C: #include <stdio.h>
#include <stdlib.h>

typedef struct {
    char *word;
    int weight;
} item_t;

item_t items[] = {
    {"alliance",     -624},
    {"archbishop",   -915},
    {"balm",          397},
    {"bonnet",        452},
    {"brute",         870},
    {"centipede",    -658},
    {"cobol",         362},
    {"covariate",     590},
    {"departure",     952},
    {"deploy",         44},
    {"diophantine",   645},
    {"efferent",       54},
    {"elysee",       -326},
    {"eradicate",     376},
    {"escritoire",    856},
    {"exorcism",     -983},
    {"fiat",          170},
    {"filmy",        -874},
    {"flatworm",      503},
    {"gestapo",       915},
    {"infra",        -847},
    {"isis",         -982},
    {"lindholm",      999},
    {"markham",       475},
    {"mincemeat",    -880},
    {"moresby",       756},
    {"mycenae",       183},
    {"plugging",     -266},
    {"smokescreen",   423},
    {"speakeasy",    -745},
    {"vein",          813},
};

int n = sizeof (items) / sizeof (item_t);
int *set;

void subsum (int i, int weight) {
    int j;
    if (i && !weight) {
        for (j = 0; j < i; j++) {
            item_t item = items[set[j]];
            printf("%s%s", j ? " " : "", items[set[j]].word);
        }
        printf("\n");
    }
    for (j = i ? set[i - 1] + 1: 0; j < n; j++) {
        set[i] = j;
        subsum(i + 1, weight + items[j].weight);
    }
}

int main () {
    set = malloc(n * sizeof (int));
    subsum(0, 0);
    return 0;
}

Python: words = { 
	"alliance": -624,	"archbishop": -925,	"balm":	397,
	"bonnet": 452,		"brute": 870,		"centipede": -658,
	"cobol": 362,		"covariate": 590,	"departure": 952,
	"deploy": 44,		"diophantine": 645,	"efferent": 54,
	"elysee": -326,		"eradicate": 376,	"escritoire": 856,
	"exorcism": -983,	"fiat": 170,		"filmy": -874,
	"flatworm": 503,	"gestapo": 915,		"infra": -847,
	"isis": -982,		"lindholm": 999,	"markham": 475,
	"mincemeat": -880,	"moresby": 756,		"mycenae": 183,
	"plugging": -266,	"smokescreen": 423,	"speakeasy": -745,
	"vein": 813
}

neg = 0
pos = 0
for (w,v) in words.iteritems():
	if v > 0: pos += v
	else:     neg += v

sums = [0] * (pos - neg + 1)

for (w,v) in words.iteritems():
	s = sums[:]
	if not s[v - neg]: s[v - neg] = (w,)

	for (i, w2) in enumerate(sums):
		if w2 and not s[i + v]:
			s[i + v] = w2 + (w,)

	sums = s
	if s[-neg]:
		for x in s[-neg]:
			print(x, words[x])
		break
Task: Subset sum problem
Go: package main

import "fmt"

type ww struct {
    word   string
    weight int
}

var input = []*ww{
    {"alliance", -624},
    {"archbishop", -915},
    {"balm", 397},
    {"bonnet", 452},
    {"brute", 870},
    {"centipede", -658},
    {"cobol", 362},
    {"covariate", 590},
    {"departure", 952},
    {"deploy", 44},
    {"diophantine", 645},
    {"efferent", 54},
    {"elysee", -326},
    {"eradicate", 376},
    {"escritoire", 856},
    {"exorcism", -983},
    {"fiat", 170},
    {"filmy", -874},
    {"flatworm", 503},
    {"gestapo", 915},
    {"infra", -847},
    {"isis", -982},
    {"lindholm", 999},
    {"markham", 475},
    {"mincemeat", -880},
    {"moresby", 756},
    {"mycenae", 183},
    {"plugging", -266},
    {"smokescreen", 423},
    {"speakeasy", -745},
    {"vein", 813},
}

type sss struct {
    subset []*ww
    sum    int
}

func main() {
    ps := []sss{{nil, 0}}
    for _, i := range input {
        pl := len(ps)
        for j := 0; j < pl; j++ {
            subset := append([]*ww{i}, ps[j].subset...)
            sum := i.weight + ps[j].sum
            if sum == 0 {
                fmt.Println("this subset sums to 0:")
                for _, i := range subset {
                    fmt.Println(*i)
                }
                return
            }
            ps = append(ps, sss{subset, sum})
        }
    }
    fmt.Println("no subset sums to 0")
}

Python: words = { 
	"alliance": -624,	"archbishop": -925,	"balm":	397,
	"bonnet": 452,		"brute": 870,		"centipede": -658,
	"cobol": 362,		"covariate": 590,	"departure": 952,
	"deploy": 44,		"diophantine": 645,	"efferent": 54,
	"elysee": -326,		"eradicate": 376,	"escritoire": 856,
	"exorcism": -983,	"fiat": 170,		"filmy": -874,
	"flatworm": 503,	"gestapo": 915,		"infra": -847,
	"isis": -982,		"lindholm": 999,	"markham": 475,
	"mincemeat": -880,	"moresby": 756,		"mycenae": 183,
	"plugging": -266,	"smokescreen": 423,	"speakeasy": -745,
	"vein": 813
}

neg = 0
pos = 0
for (w,v) in words.iteritems():
	if v > 0: pos += v
	else:     neg += v

sums = [0] * (pos - neg + 1)

for (w,v) in words.iteritems():
	s = sums[:]
	if not s[v - neg]: s[v - neg] = (w,)

	for (i, w2) in enumerate(sums):
		if w2 and not s[i + v]:
			s[i + v] = w2 + (w,)

	sums = s
	if s[-neg]:
		for x in s[-neg]:
			print(x, words[x])
		break
Task: Find words which contains more than 3 e vowels
C: #include <stdio.h>
#define SIZE 256

int check(char *word) {
    int e = 0, ok = 1;
    for(; *word && ok; word++) {
        switch(*word) {
            case 'a':
            case 'i':
            case 'o':
            case 'u': ok = 0; break;
            case 'e': e++;
        }
    }
    
    return ok && e > 3;
}
    
int main() {
    FILE *f;
    char line[SIZE];
    
    if (!(f = fopen("unixdict.txt", "r"))) {
        fprintf(stderr, "Cannot open unixdict.txt\n");
        return 1;
    }
    
    while (!feof(f)) {
        fgets(line, SIZE, f);
        if (check(line)) printf("%s", line);
    }
    
    fclose(f);
    return 0;
}

C#: #include <iostream>
#include <fstream>

bool test(const std::string &line) {
    unsigned int e = 0;
    for (char c : line) {
        switch(std::tolower(c)) {
            case 'a': return false;
            case 'i': return false;
            case 'o': return false;
            case 'u': return false;
            case 'e': ++e;
        }
    }
    return e > 3;
}

int main() {
    std::ifstream dict{"unixdict.txt"};
    
    if (! dict.is_open()) {
        std::cerr << "Cannot open unixdict.txt\n";
        return 3;
    }
    
    for (std::string line; std::getline(dict, line);) {
        if (test(line)) std::cout << line << std::endl;
    }
    
    return 0;
}
Task: Find words which contains more than 3 e vowels
C: #include <stdio.h>
#define SIZE 256

int check(char *word) {
    int e = 0, ok = 1;
    for(; *word && ok; word++) {
        switch(*word) {
            case 'a':
            case 'i':
            case 'o':
            case 'u': ok = 0; break;
            case 'e': e++;
        }
    }
    
    return ok && e > 3;
}
    
int main() {
    FILE *f;
    char line[SIZE];
    
    if (!(f = fopen("unixdict.txt", "r"))) {
        fprintf(stderr, "Cannot open unixdict.txt\n");
        return 1;
    }
    
    while (!feof(f)) {
        fgets(line, SIZE, f);
        if (check(line)) printf("%s", line);
    }
    
    fclose(f);
    return 0;
}

Go: package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "log"
    "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 []string
outer:
    for _, bword := range bwords {
        s := string(bword)
        if utf8.RuneCountInString(s) >= 4 {
            for _, c := range s {
                if strings.ContainsRune("aiou", c) {
                    continue outer
                }
            }
            words = append(words, s)
        }
    }
    wcount := 0
    for _, word := range words {
        ecount := 0
        for _, c := range word {
            if c == 'e' {
                ecount++
            }
        }
        if ecount > 3 {
            wcount++
            fmt.Printf("%2d: %s\n", wcount, word)
        }
    }
}
Task: Find words which contains more than 3 e vowels
C: #include <stdio.h>
#define SIZE 256

int check(char *word) {
    int e = 0, ok = 1;
    for(; *word && ok; word++) {
        switch(*word) {
            case 'a':
            case 'i':
            case 'o':
            case 'u': ok = 0; break;
            case 'e': e++;
        }
    }
    
    return ok && e > 3;
}
    
int main() {
    FILE *f;
    char line[SIZE];
    
    if (!(f = fopen("unixdict.txt", "r"))) {
        fprintf(stderr, "Cannot open unixdict.txt\n");
        return 1;
    }
    
    while (!feof(f)) {
        fgets(line, SIZE, f);
        if (check(line)) printf("%s", line);
    }
    
    fclose(f);
    return 0;
}

Python: with open('unixdict.txt', 'rt') as f:
    for line in f.readlines():
        if not any(c in 'aiou' for c in line) and sum(c=='e' for c in line)>3:
            print(line.strip())
Task: Find words which contains more than 3 e vowels
C++: #include <iostream>
#include <fstream>

bool test(const std::string &line) {
    unsigned int e = 0;
    for (char c : line) {
        switch(std::tolower(c)) {
            case 'a': return false;
            case 'i': return false;
            case 'o': return false;
            case 'u': return false;
            case 'e': ++e;
        }
    }
    return e > 3;
}

int main() {
    std::ifstream dict{"unixdict.txt"};
    
    if (! dict.is_open()) {
        std::cerr << "Cannot open unixdict.txt\n";
        return 3;
    }
    
    for (std::string line; std::getline(dict, line);) {
        if (test(line)) std::cout << line << std::endl;
    }
    
    return 0;
}

Python: with open('unixdict.txt', 'rt') as f:
    for line in f.readlines():
        if not any(c in 'aiou' for c in line) and sum(c=='e' for c in line)>3:
            print(line.strip())
Task: Find words which contains more than 3 e vowels
C: #include <stdio.h>
#define SIZE 256

int check(char *word) {
    int e = 0, ok = 1;
    for(; *word && ok; word++) {
        switch(*word) {
            case 'a':
            case 'i':
            case 'o':
            case 'u': ok = 0; break;
            case 'e': e++;
        }
    }
    
    return ok && e > 3;
}
    
int main() {
    FILE *f;
    char line[SIZE];
    
    if (!(f = fopen("unixdict.txt", "r"))) {
        fprintf(stderr, "Cannot open unixdict.txt\n");
        return 1;
    }
    
    while (!feof(f)) {
        fgets(line, SIZE, f);
        if (check(line)) printf("%s", line);
    }
    
    fclose(f);
    return 0;
}

C++: #include <iostream>
#include <fstream>

bool test(const std::string &line) {
    unsigned int e = 0;
    for (char c : line) {
        switch(std::tolower(c)) {
            case 'a': return false;
            case 'i': return false;
            case 'o': return false;
            case 'u': return false;
            case 'e': ++e;
        }
    }
    return e > 3;
}

int main() {
    std::ifstream dict{"unixdict.txt"};
    
    if (! dict.is_open()) {
        std::cerr << "Cannot open unixdict.txt\n";
        return 3;
    }
    
    for (std::string line; std::getline(dict, line);) {
        if (test(line)) std::cout << line << std::endl;
    }
    
    return 0;
}
Task: Find words which contains more than 3 e vowels
Go: package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "log"
    "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 []string
outer:
    for _, bword := range bwords {
        s := string(bword)
        if utf8.RuneCountInString(s) >= 4 {
            for _, c := range s {
                if strings.ContainsRune("aiou", c) {
                    continue outer
                }
            }
            words = append(words, s)
        }
    }
    wcount := 0
    for _, word := range words {
        ecount := 0
        for _, c := range word {
            if c == 'e' {
                ecount++
            }
        }
        if ecount > 3 {
            wcount++
            fmt.Printf("%2d: %s\n", wcount, word)
        }
    }
}

Python: with open('unixdict.txt', 'rt') as f:
    for line in f.readlines():
        if not any(c in 'aiou' for c in line) and sum(c=='e' for c in line)>3:
            print(line.strip())
Task: Find words which contains more than 3 e vowels
C++: #include <iostream>
#include <fstream>

bool test(const std::string &line) {
    unsigned int e = 0;
    for (char c : line) {
        switch(std::tolower(c)) {
            case 'a': return false;
            case 'i': return false;
            case 'o': return false;
            case 'u': return false;
            case 'e': ++e;
        }
    }
    return e > 3;
}

int main() {
    std::ifstream dict{"unixdict.txt"};
    
    if (! dict.is_open()) {
        std::cerr << "Cannot open unixdict.txt\n";
        return 3;
    }
    
    for (std::string line; std::getline(dict, line);) {
        if (test(line)) std::cout << line << std::endl;
    }
    
    return 0;
}

Go: package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "log"
    "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 []string
outer:
    for _, bword := range bwords {
        s := string(bword)
        if utf8.RuneCountInString(s) >= 4 {
            for _, c := range s {
                if strings.ContainsRune("aiou", c) {
                    continue outer
                }
            }
            words = append(words, s)
        }
    }
    wcount := 0
    for _, word := range words {
        ecount := 0
        for _, c := range word {
            if c == 'e' {
                ecount++
            }
        }
        if ecount > 3 {
            wcount++
            fmt.Printf("%2d: %s\n", wcount, word)
        }
    }
}
Task: Guess the number
C: #include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main(void)
{
    int n;
    int g;
    char c;

    srand(time(NULL));
    n = 1 + (rand() % 10);

    puts("I'm thinking of a number between 1 and 10.");
    puts("Try to guess it:");

    while (1) {
        if (scanf("%d", &g) != 1) {
		
		scanf("%c", &c);
		continue;
	}

        if (g == n) {
	    puts("Correct!");
	    return 0;
	}
        puts("That's not my number. Try another guess:");
    }
}

C#: using System;

class GuessTheNumberGame
{
    static void Main()
    {
        int randomNumber = new Random().Next(1, 11);
        
        Console.WriteLine("I'm thinking of a number between 1 and 10. Can you guess it?");
        while(true)
        {
            Console.Write("Guess: ");
            if (int.Parse(Console.ReadLine()) == randomNumber)
                break;
            Console.WriteLine("That's not it. Guess again.");
        }
        Console.WriteLine("Congrats!! You guessed right!");
    }
};
Task: Guess the number
C: #include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main(void)
{
    int n;
    int g;
    char c;

    srand(time(NULL));
    n = 1 + (rand() % 10);

    puts("I'm thinking of a number between 1 and 10.");
    puts("Try to guess it:");

    while (1) {
        if (scanf("%d", &g) != 1) {
		
		scanf("%c", &c);
		continue;
	}

        if (g == n) {
	    puts("Correct!");
	    return 0;
	}
        puts("That's not my number. Try another guess:");
    }
}

C++: #include <iostream>
#include <cstdlib>
#include <ctime>

int main()
{
    srand(time(0));
    int n = 1 + (rand() % 10);
    int g;
    std::cout << "I'm thinking of a number between 1 and 10.\nTry to guess it! ";
    while(true)
    {
        std::cin >> g;
        if (g == n)
            break;
        else
            std::cout << "That's not my number.\nTry another guess! ";
    }
    std::cout << "You've guessed my number!";
    return 0;
}