Hello, world!

Примеры программ

Сумма чисел от 1 до n на питоне

import time

n = 100
s = 0
for i in range(1, n + 1):
    s += i
print(s)
print(time.clock())

Сумма чисел от 1 до n на С++

#include <ctime>
#include <iostream>

using namespace std;

int main()
{
    const int N = 100;
    int s = 0;
    for (int i = 1; i <= N; ++i)
        s += i;
    cout << s << endl;
    cout << clock() / (double) CLOCKS_PER_SEC << endl;
}

Сумма чисел от 1 до n с сохранением в массиве

#include <ctime>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    const int N = 100;
    vector <int> a (N);
    for (int i = 0; i < N; ++i)
        a[i] = i + 1;
    int s = 0;
    for (int i = 0; i < N; ++i)
        s += a[i];
    cout << s << endl;
    cout << clock() / (double) CLOCKS_PER_SEC << endl;
}