WeixiangYan/CodeTransOcean huggingface dataset:
Task: Digit fifth powers

C: #include<stdio.h>
#include<stdlib.h>
#include<math.h>

int sum5( int n ) {
    if(n<10) return pow(n,5);
    return pow(n%10,5) + sum5(n/10);
}

int main(void) {
    int i, sum = 0;
    for(i=2;i<=999999;i++) {
        if(i==sum5(i)) {
            printf( "%d\n", i );
            sum+=i;
        }
    }
    printf( "Total is %d\n", sum );
    return 0;
}



C#: #include <iostream>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;

int main() {
  auto st = high_resolution_clock::now();
  const uint i5 = 100000, i4 = 10000, i3 = 1000, i2 = 100, i1 = 10;
  uint p4[] = { 0, 1, 32, 243 }, nums[10], p5[10], t = 0, 
    m5, m4, m3, m2, m1, m0; m5 = m4 = m3 = m2 = m1 = m0 = 0;
  for (uint i = 0; i < 10; i++) p5[i] = pow(nums[i] = i, 5);
  for (auto i : p4) { auto im =      m5, ip =      i; m4 = 0;
  for (auto j : p5) { auto jm = im + m4, jp = ip + j; m3 = 0;
  for (auto k : p5) { auto km = jm + m3, kp = jp + k; m2 = 0;
  for (auto l : p5) { auto lm = km + m2, lp = kp + l; m1 = 0;
  for (auto m : p5) { auto mm = lm + m1, mp = lp + m; m0 = 0;
  for (auto n : p5) { auto nm = mm + m0++;
    if (nm == mp + n && nm > 1) t += nm;
  } m1 += i1; } m2 += i2; } m3 += i3; } m4 += i4; } m5 += i5; }
  auto et = high_resolution_clock::now();
  std::cout << t << " " <<
    duration_cast<nanoseconds>(et - st).count() / 1000.0 << " μs";
}
Task: Digit fifth powers

C: #include<stdio.h>
#include<stdlib.h>
#include<math.h>

int sum5( int n ) {
    if(n<10) return pow(n,5);
    return pow(n%10,5) + sum5(n/10);
}

int main(void) {
    int i, sum = 0;
    for(i=2;i<=999999;i++) {
        if(i==sum5(i)) {
            printf( "%d\n", i );
            sum+=i;
        }
    }
    printf( "Total is %d\n", sum );
    return 0;
}


C++: #include <iostream>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;

int main() {
  auto st = high_resolution_clock::now();
  const uint i5 = 100000, i4 = 10000, i3 = 1000, i2 = 100, i1 = 10;
  uint p4[] = { 0, 1, 32, 243 }, nums[10], p5[10], t = 0, 
    m5, m4, m3, m2, m1, m0; m5 = m4 = m3 = m2 = m1 = m0 = 0;
  for (uint i = 0; i < 10; i++) p5[i] = pow(nums[i] = i, 5);
  for (auto i : p4) { auto im =      m5, ip =      i; m4 = 0;
  for (auto j : p5) { auto jm = im + m4, jp = ip + j; m3 = 0;
  for (auto k : p5) { auto km = jm + m3, kp = jp + k; m2 = 0;
  for (auto l : p5) { auto lm = km + m2, lp = kp + l; m1 = 0;
  for (auto m : p5) { auto mm = lm + m1, mp = lp + m; m0 = 0;
  for (auto n : p5) { auto nm = mm + m0++;
    if (nm == mp + n && nm > 1) t += nm;
  } m1 += i1; } m2 += i2; } m3 += i3; } m4 += i4; } m5 += i5; }
  auto et = high_resolution_clock::now();
  std::cout << t << " " <<
    duration_cast<nanoseconds>(et - st).count() / 1000.0 << " μs";
}
Task: Digit fifth powers

C: #include<stdio.h>
#include<stdlib.h>
#include<math.h>

int sum5( int n ) {
    if(n<10) return pow(n,5);
    return pow(n%10,5) + sum5(n/10);
}

int main(void) {
    int i, sum = 0;
    for(i=2;i<=999999;i++) {
        if(i==sum5(i)) {
            printf( "%d\n", i );
            sum+=i;
        }
    }
    printf( "Total is %d\n", sum );
    return 0;
}




Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    
    dp5 := [10]int{0, 1}
    for i := 2; i < 10; i++ {
        ii := i * i
        dp5[i] = ii * ii * i
    }
    fmt.Println("The sum of all numbers that can be written as the sum of the 5th powers of their digits is:")
    limit := dp5[9] * 6
    sum := 0
    for i := 2; i <= limit; i++ {
        digits := rcu.Digits(i, 10)
        totalDp := 0
        for _, d := range digits {
            totalDp += dp5[d]
        }
        if totalDp == i {
            if sum > 0 {
                fmt.Printf(" + %d", i)
            } else {
                fmt.Print(i)
            }
            sum += i
        }
    }
    fmt.Printf(" = %d\n", sum)
}
Task: Digit fifth powers

C: #include<stdio.h>
#include<stdlib.h>
#include<math.h>

int sum5( int n ) {
    if(n<10) return pow(n,5);
    return pow(n%10,5) + sum5(n/10);
}

int main(void) {
    int i, sum = 0;
    for(i=2;i<=999999;i++) {
        if(i==sum5(i)) {
            printf( "%d\n", i );
            sum+=i;
        }
    }
    printf( "Total is %d\n", sum );
    return 0;
}







Python: from time import time


st = time()
print(sum([n for n in range(2, 6*9**5) if sum(int(i)**5 for i in str(n)) == n]), "  ", (time() - st) * 1000, "ms")


st = time()
nums = list(range(10))
nu = list(range(((6 * 9**5) // 100000) + 1))
numbers = []
p5 = []
for i in nums: p5.append(i**5)
for i in nu:
    im = i * 100000
    ip = p5[i]
    for j in nums:
        jm = im + 10000 * j
        jp = ip + p5[j]
        for k in nums:
            km = jm + 1000 * k
            kp = jp + p5[k]
            for l in nums:
                lm = km + 100 * l
                lp = kp + p5[l]
                for m in nums:
                    mm = lm + 10 * m
                    mp = lp + p5[m]
                    for n in nums:
                        nm = mm + n
                        np = mp + p5[n]
                        if np == nm:
                            if nm > 1: numbers.append(nm)
print(sum(numbers), "  ", (time() - st) * 1000, "ms", end = "")
Task: Digit fifth powers


C++: #include <iostream>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;

int main() {
  auto st = high_resolution_clock::now();
  const uint i5 = 100000, i4 = 10000, i3 = 1000, i2 = 100, i1 = 10;
  uint p4[] = { 0, 1, 32, 243 }, nums[10], p5[10], t = 0, 
    m5, m4, m3, m2, m1, m0; m5 = m4 = m3 = m2 = m1 = m0 = 0;
  for (uint i = 0; i < 10; i++) p5[i] = pow(nums[i] = i, 5);
  for (auto i : p4) { auto im =      m5, ip =      i; m4 = 0;
  for (auto j : p5) { auto jm = im + m4, jp = ip + j; m3 = 0;
  for (auto k : p5) { auto km = jm + m3, kp = jp + k; m2 = 0;
  for (auto l : p5) { auto lm = km + m2, lp = kp + l; m1 = 0;
  for (auto m : p5) { auto mm = lm + m1, mp = lp + m; m0 = 0;
  for (auto n : p5) { auto nm = mm + m0++;
    if (nm == mp + n && nm > 1) t += nm;
  } m1 += i1; } m2 += i2; } m3 += i3; } m4 += i4; } m5 += i5; }
  auto et = high_resolution_clock::now();
  std::cout << t << " " <<
    duration_cast<nanoseconds>(et - st).count() / 1000.0 << " μs";
}



Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    
    dp5 := [10]int{0, 1}
    for i := 2; i < 10; i++ {
        ii := i * i
        dp5[i] = ii * ii * i
    }
    fmt.Println("The sum of all numbers that can be written as the sum of the 5th powers of their digits is:")
    limit := dp5[9] * 6
    sum := 0
    for i := 2; i <= limit; i++ {
        digits := rcu.Digits(i, 10)
        totalDp := 0
        for _, d := range digits {
            totalDp += dp5[d]
        }
        if totalDp == i {
            if sum > 0 {
                fmt.Printf(" + %d", i)
            } else {
                fmt.Print(i)
            }
            sum += i
        }
    }
    fmt.Printf(" = %d\n", sum)
}
Task: Digit fifth powers


C++: #include <iostream>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;

int main() {
  auto st = high_resolution_clock::now();
  const uint i5 = 100000, i4 = 10000, i3 = 1000, i2 = 100, i1 = 10;
  uint p4[] = { 0, 1, 32, 243 }, nums[10], p5[10], t = 0, 
    m5, m4, m3, m2, m1, m0; m5 = m4 = m3 = m2 = m1 = m0 = 0;
  for (uint i = 0; i < 10; i++) p5[i] = pow(nums[i] = i, 5);
  for (auto i : p4) { auto im =      m5, ip =      i; m4 = 0;
  for (auto j : p5) { auto jm = im + m4, jp = ip + j; m3 = 0;
  for (auto k : p5) { auto km = jm + m3, kp = jp + k; m2 = 0;
  for (auto l : p5) { auto lm = km + m2, lp = kp + l; m1 = 0;
  for (auto m : p5) { auto mm = lm + m1, mp = lp + m; m0 = 0;
  for (auto n : p5) { auto nm = mm + m0++;
    if (nm == mp + n && nm > 1) t += nm;
  } m1 += i1; } m2 += i2; } m3 += i3; } m4 += i4; } m5 += i5; }
  auto et = high_resolution_clock::now();
  std::cout << t << " " <<
    duration_cast<nanoseconds>(et - st).count() / 1000.0 << " μs";
}






Python: from time import time


st = time()
print(sum([n for n in range(2, 6*9**5) if sum(int(i)**5 for i in str(n)) == n]), "  ", (time() - st) * 1000, "ms")


st = time()
nums = list(range(10))
nu = list(range(((6 * 9**5) // 100000) + 1))
numbers = []
p5 = []
for i in nums: p5.append(i**5)
for i in nu:
    im = i * 100000
    ip = p5[i]
    for j in nums:
        jm = im + 10000 * j
        jp = ip + p5[j]
        for k in nums:
            km = jm + 1000 * k
            kp = jp + p5[k]
            for l in nums:
                lm = km + 100 * l
                lp = kp + p5[l]
                for m in nums:
                    mm = lm + 10 * m
                    mp = lp + p5[m]
                    for n in nums:
                        nm = mm + n
                        np = mp + p5[n]
                        if np == nm:
                            if nm > 1: numbers.append(nm)
print(sum(numbers), "  ", (time() - st) * 1000, "ms", end = "")
Task: Digit fifth powers




Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    
    dp5 := [10]int{0, 1}
    for i := 2; i < 10; i++ {
        ii := i * i
        dp5[i] = ii * ii * i
    }
    fmt.Println("The sum of all numbers that can be written as the sum of the 5th powers of their digits is:")
    limit := dp5[9] * 6
    sum := 0
    for i := 2; i <= limit; i++ {
        digits := rcu.Digits(i, 10)
        totalDp := 0
        for _, d := range digits {
            totalDp += dp5[d]
        }
        if totalDp == i {
            if sum > 0 {
                fmt.Printf(" + %d", i)
            } else {
                fmt.Print(i)
            }
            sum += i
        }
    }
    fmt.Printf(" = %d\n", sum)
}




Python: from time import time


st = time()
print(sum([n for n in range(2, 6*9**5) if sum(int(i)**5 for i in str(n)) == n]), "  ", (time() - st) * 1000, "ms")


st = time()
nums = list(range(10))
nu = list(range(((6 * 9**5) // 100000) + 1))
numbers = []
p5 = []
for i in nums: p5.append(i**5)
for i in nu:
    im = i * 100000
    ip = p5[i]
    for j in nums:
        jm = im + 10000 * j
        jp = ip + p5[j]
        for k in nums:
            km = jm + 1000 * k
            kp = jp + p5[k]
            for l in nums:
                lm = km + 100 * l
                lp = kp + p5[l]
                for m in nums:
                    mm = lm + 10 * m
                    mp = lp + p5[m]
                    for n in nums:
                        nm = mm + n
                        np = mp + p5[n]
                        if np == nm:
                            if nm > 1: numbers.append(nm)
print(sum(numbers), "  ", (time() - st) * 1000, "ms", end = "")
Task: Simple windowed application

C: #include <stdio.h>
#include <gtk/gtk.h>

const gchar *clickme = "Click Me";
guint counter = 0;

#define MAXLEN 64
void clickedme(GtkButton *o, gpointer d)
{
    GtkLabel *l = GTK_LABEL(d);
    char nt[MAXLEN];
    
    counter++;
    snprintf(nt, MAXLEN, "You clicked me %d times", counter);
    gtk_label_set_text(l, nt);
}

int main(int argc, char **argv)
{
    GtkWindow *win;
    GtkButton *button;
    GtkLabel *label;
    GtkVBox *vbox;

    gtk_init(&argc, &argv);
    win = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(win, clickme);
    button = (GtkButton*)gtk_button_new_with_label(clickme);
    label = (GtkLabel*)gtk_label_new("There have been no clicks yet");
    gtk_label_set_single_line_mode(label, TRUE);
    vbox = (GtkVBox*)gtk_vbox_new(TRUE, 1);
    gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(label));
    gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(button));
    gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
    g_signal_connect(G_OBJECT(win), "delete-event", (GCallback)gtk_main_quit, NULL);
    g_signal_connect(G_OBJECT(button), "clicked", (GCallback)clickedme, label);
    gtk_widget_show_all(GTK_WIDGET(win));
    gtk_main();
    return 0;
}



C#: using System.Windows.Forms;

class RosettaForm : Form
{
    RosettaForm()
    {
        var clickCount = 0;

        var label = new Label();
        label.Text = "There have been no clicks yet.";
        label.Dock = DockStyle.Top;
        Controls.Add(label);

        var button = new Button();
        button.Text = "Click Me";
        button.Dock = DockStyle.Bottom;
        button.Click += delegate
                        {
                            clickCount++;
                            label.Text = "Number of clicks: " + clickCount + ".";
                        };
        Controls.Add(button);
    }

    static void Main()
    {
        Application.Run(new RosettaForm());
    }
}
Task: Simple windowed application

C: #include <stdio.h>
#include <gtk/gtk.h>

const gchar *clickme = "Click Me";
guint counter = 0;

#define MAXLEN 64
void clickedme(GtkButton *o, gpointer d)
{
    GtkLabel *l = GTK_LABEL(d);
    char nt[MAXLEN];
    
    counter++;
    snprintf(nt, MAXLEN, "You clicked me %d times", counter);
    gtk_label_set_text(l, nt);
}

int main(int argc, char **argv)
{
    GtkWindow *win;
    GtkButton *button;
    GtkLabel *label;
    GtkVBox *vbox;

    gtk_init(&argc, &argv);
    win = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(win, clickme);
    button = (GtkButton*)gtk_button_new_with_label(clickme);
    label = (GtkLabel*)gtk_label_new("There have been no clicks yet");
    gtk_label_set_single_line_mode(label, TRUE);
    vbox = (GtkVBox*)gtk_vbox_new(TRUE, 1);
    gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(label));
    gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(button));
    gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
    g_signal_connect(G_OBJECT(win), "delete-event", (GCallback)gtk_main_quit, NULL);
    g_signal_connect(G_OBJECT(button), "clicked", (GCallback)clickedme, label);
    gtk_widget_show_all(GTK_WIDGET(win));
    gtk_main();
    return 0;
}


C++: #ifndef CLICKCOUNTER_H
#define CLICKCOUNTER_H

#include <QWidget>
class QLabel ;
class QPushButton ;
class QVBoxLayout ;

class Counter : public QWidget {
    Q_OBJECT
public :
   Counter( QWidget * parent = 0 ) ;
private :
   int number ;
   QLabel *countLabel ;
   QPushButton *clicker ;
   QVBoxLayout *myLayout ;
private slots :
   void countClicks( ) ;
} ;
#endif
Task: Simple windowed application

C: #include <stdio.h>
#include <gtk/gtk.h>

const gchar *clickme = "Click Me";
guint counter = 0;

#define MAXLEN 64
void clickedme(GtkButton *o, gpointer d)
{
    GtkLabel *l = GTK_LABEL(d);
    char nt[MAXLEN];
    
    counter++;
    snprintf(nt, MAXLEN, "You clicked me %d times", counter);
    gtk_label_set_text(l, nt);
}

int main(int argc, char **argv)
{
    GtkWindow *win;
    GtkButton *button;
    GtkLabel *label;
    GtkVBox *vbox;

    gtk_init(&argc, &argv);
    win = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(win, clickme);
    button = (GtkButton*)gtk_button_new_with_label(clickme);
    label = (GtkLabel*)gtk_label_new("There have been no clicks yet");
    gtk_label_set_single_line_mode(label, TRUE);
    vbox = (GtkVBox*)gtk_vbox_new(TRUE, 1);
    gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(label));
    gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(button));
    gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
    g_signal_connect(G_OBJECT(win), "delete-event", (GCallback)gtk_main_quit, NULL);
    g_signal_connect(G_OBJECT(button), "clicked", (GCallback)clickedme, label);
    gtk_widget_show_all(GTK_WIDGET(win));
    gtk_main();
    return 0;
}




Go: package main

import (
    "fmt"
    "github.com/mattn/go-gtk/gtk"
)

func main() {
    gtk.Init(nil)
    window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
    window.SetTitle("Click me")
    label := gtk.NewLabel("There have been no clicks yet")
    var clicks int
    button := gtk.NewButtonWithLabel("click me")
    button.Clicked(func() {
        clicks++
        if clicks == 1 {
            label.SetLabel("Button clicked 1 time")
        } else {
            label.SetLabel(fmt.Sprintf("Button clicked %d times",
                clicks))
        }
    })
    vbox := gtk.NewVBox(false, 1)
    vbox.Add(label)
    vbox.Add(button)
    window.Add(vbox)
    window.Connect("destroy", func() {
        gtk.MainQuit()
    })
    window.ShowAll()
    gtk.Main()
}
Task: Simple windowed application

C: #include <stdio.h>
#include <gtk/gtk.h>

const gchar *clickme = "Click Me";
guint counter = 0;

#define MAXLEN 64
void clickedme(GtkButton *o, gpointer d)
{
    GtkLabel *l = GTK_LABEL(d);
    char nt[MAXLEN];
    
    counter++;
    snprintf(nt, MAXLEN, "You clicked me %d times", counter);
    gtk_label_set_text(l, nt);
}

int main(int argc, char **argv)
{
    GtkWindow *win;
    GtkButton *button;
    GtkLabel *label;
    GtkVBox *vbox;

    gtk_init(&argc, &argv);
    win = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(win, clickme);
    button = (GtkButton*)gtk_button_new_with_label(clickme);
    label = (GtkLabel*)gtk_label_new("There have been no clicks yet");
    gtk_label_set_single_line_mode(label, TRUE);
    vbox = (GtkVBox*)gtk_vbox_new(TRUE, 1);
    gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(label));
    gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(button));
    gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
    g_signal_connect(G_OBJECT(win), "delete-event", (GCallback)gtk_main_quit, NULL);
    g_signal_connect(G_OBJECT(button), "clicked", (GCallback)clickedme, label);
    gtk_widget_show_all(GTK_WIDGET(win));
    gtk_main();
    return 0;
}








VB: VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "There have been no clicks yet"
   ClientHeight    =   2940
   ClientLeft      =   60
   ClientTop       =   600
   ClientWidth     =   8340
   LinkTopic       =   "Form1"
   ScaleHeight     =   2940
   ScaleWidth      =   8340
   StartUpPosition =   3  
   Begin VB.CommandButton Command1 
      Caption         =   "Click me!"
      Height          =   495
      Left            =   3600
      TabIndex        =   0
      Top             =   1200
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private clicked As Long

Private Sub Command1_Click()
    clicked = clicked + 1
    Me.Caption = clicked & " clicks."
End Sub
Task: Simple windowed application


C++: #ifndef CLICKCOUNTER_H
#define CLICKCOUNTER_H

#include <QWidget>
class QLabel ;
class QPushButton ;
class QVBoxLayout ;

class Counter : public QWidget {
    Q_OBJECT
public :
   Counter( QWidget * parent = 0 ) ;
private :
   int number ;
   QLabel *countLabel ;
   QPushButton *clicker ;
   QVBoxLayout *myLayout ;
private slots :
   void countClicks( ) ;
} ;
#endif



Go: package main

import (
    "fmt"
    "github.com/mattn/go-gtk/gtk"
)

func main() {
    gtk.Init(nil)
    window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
    window.SetTitle("Click me")
    label := gtk.NewLabel("There have been no clicks yet")
    var clicks int
    button := gtk.NewButtonWithLabel("click me")
    button.Clicked(func() {
        clicks++
        if clicks == 1 {
            label.SetLabel("Button clicked 1 time")
        } else {
            label.SetLabel(fmt.Sprintf("Button clicked %d times",
                clicks))
        }
    })
    vbox := gtk.NewVBox(false, 1)
    vbox.Add(label)
    vbox.Add(button)
    window.Add(vbox)
    window.Connect("destroy", func() {
        gtk.MainQuit()
    })
    window.ShowAll()
    gtk.Main()
}
Task: Simple windowed application


C++: #ifndef CLICKCOUNTER_H
#define CLICKCOUNTER_H

#include <QWidget>
class QLabel ;
class QPushButton ;
class QVBoxLayout ;

class Counter : public QWidget {
    Q_OBJECT
public :
   Counter( QWidget * parent = 0 ) ;
private :
   int number ;
   QLabel *countLabel ;
   QPushButton *clicker ;
   QVBoxLayout *myLayout ;
private slots :
   void countClicks( ) ;
} ;
#endif




Java: import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class Clicks extends JFrame{
	private long clicks = 0;

	public Clicks(){
		super("Clicks");
		JLabel label = new JLabel("There have been no clicks yet");
		JButton clicker = new JButton("click me");
		clicker.addActionListener(
			new ActionListener(){
				@Override
				public void actionPerformed(ActionEvent e) {
					label.setText("There have been " + (++clicks) + " clicks");
				}
			}
		);
		setLayout(new BorderLayout());
		add(label,BorderLayout.CENTER);
		add(clicker,BorderLayout.SOUTH);
		label.setPreferredSize(new Dimension(300,100));
		label.setHorizontalAlignment(JLabel.CENTER);
		pack();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
	}
	public static void main(String[] args){
		SwingUtilities.invokeLater( 
			() -> new Clicks() 
		);
	}
}
Task: Simple windowed application


C++: #ifndef CLICKCOUNTER_H
#define CLICKCOUNTER_H

#include <QWidget>
class QLabel ;
class QPushButton ;
class QVBoxLayout ;

class Counter : public QWidget {
    Q_OBJECT
public :
   Counter( QWidget * parent = 0 ) ;
private :
   int number ;
   QLabel *countLabel ;
   QPushButton *clicker ;
   QVBoxLayout *myLayout ;
private slots :
   void countClicks( ) ;
} ;
#endif






Python: from functools import partial
import tkinter as tk

def on_click(label: tk.Label,
             counter: tk.IntVar) -> None:
    counter.set(counter.get() + 1)
    label["text"] = f"Number of clicks: {counter.get()}"

def main():
    window = tk.Tk()
    window.geometry("200x50+100+100")
    label = tk.Label(master=window,
                     text="There have been no clicks yet")
    label.pack()
    counter = tk.IntVar()
    update_counter = partial(on_click,
                             label=label,
                             counter=counter)
    button = tk.Button(master=window,
                       text="click me",
                       command=update_counter)
    button.pack()
    window.mainloop()

if __name__ == '__main__':
    main()
Task: Simple windowed application


C++: #ifndef CLICKCOUNTER_H
#define CLICKCOUNTER_H

#include <QWidget>
class QLabel ;
class QPushButton ;
class QVBoxLayout ;

class Counter : public QWidget {
    Q_OBJECT
public :
   Counter( QWidget * parent = 0 ) ;
private :
   int number ;
   QLabel *countLabel ;
   QPushButton *clicker ;
   QVBoxLayout *myLayout ;
private slots :
   void countClicks( ) ;
} ;
#endif







VB: VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "There have been no clicks yet"
   ClientHeight    =   2940
   ClientLeft      =   60
   ClientTop       =   600
   ClientWidth     =   8340
   LinkTopic       =   "Form1"
   ScaleHeight     =   2940
   ScaleWidth      =   8340
   StartUpPosition =   3  
   Begin VB.CommandButton Command1 
      Caption         =   "Click me!"
      Height          =   495
      Left            =   3600
      TabIndex        =   0
      Top             =   1200
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private clicked As Long

Private Sub Command1_Click()
    clicked = clicked + 1
    Me.Caption = clicked & " clicks."
End Sub