Четверг, 09.05.2024, 10:01
Приветствую Вас Гость | RSS

 
 

Анти случайный математический сайт: всё Бесплатно 18+ kenokeno.ucoz.ru

Anti chaotically math site all FREE against losses против проигрышей 18+

 
Карта мира Пирамида Жизни Визуальная математика Всеобуч CoronaVirus

карта статистики посетителей & исследования и конкурсы бесплатные & ВКонтакте & Математический Блог & КеноКено & КЕНО ЮТЮБ KENO mini YOUTUBE

БЕЗ рекламы БЕЗ партнёрских БЕЗ рефералов NO advertising NO partners NO referrals pas de publicite pas de partenaires pas de references

Ссылки внутри страниц открываются в новой вкладке Links inside pages open in a new tab of browser

КЕНО ЮТЮБ KENO mini YOUTUBE КЕНО ЮТЮБ KENO mini YOUTUBE КЕНО ЮТЮБ KENO mini YOUTUBE КЕНО ЮТЮБ KENO mini YOUTUBE КЕНО ЮТЮБ KENO mini YOUTUBE КЕНО ЮТЮБ KENO mini YOUTUBE КЕНО ЮТЮБ KENO mini YOUTUBE КЕНО ЮТЮБ KENO mini YOUTUBE КЕНО ЮТЮБ KENO mini YOUTUBE

Просвещение России содержит гигантский пробел:
интегралы в любом виде в младшей школе не изучаются

даже словами отличными от слова "интеграл": "сбор"
в то время как интеграл в жизни ежесекундно: и одежда
и продукты и выбор в магазине и транспортная задача

ведь понимая интегральную суть человек сравнивает
без расчётов в уме и делает оптимальный выбор

ключевые 27

свои чужие другие
актив пассив экономия
лидер ведомый жертва
жизнь машина язык
цель время контроль
услуга товар качество
экспорт эксплуатация технология
интеграл логарифм производная
элита антиэлита приоритет

 

keywords 27

ours aliens others
active passive saving
leader slave victim
life machine language
target time control
service goods quality
export exploitation technology
integral logarithm derivative
elite antielite priority

 

 

Россия видит мир из будущего

Russia looks world from future

Rossiya vidit mir iz buduschego

IQ бесплатно Яндекс.Метрика

всегда пишу только про себя и никогда никому ничего не рекомендую

i always write only about myself and anything to anyone never recommend

мен әрқашан тек өзіме жазамын және ешқашан ешкімге ештеңе ұсынбаймын

завжди пишу тільки про себе і ніколи нікому нічого не рекомендую

web.archive.org/web/20230602154543///kenokeno.ucoz.ru/publ/

ich schreibe immer nur über mich selbst und empfehle niemandem etwas

j'écris toujours seulement sur moi-même et je ne recommande

mi ĉiam skribas nur pri mi mem kaj neniam rekomendas ion al iu

siempre escribo solo para mí y nunca recomiendo nada a nadie

web.archive.org/web/20230602152617///kenokeno.ucoz.ru/load/

 

Главная | Регистрация | Вход

 
Главная » 2022 » Октябрь » 25 » Универсальная программа
12:03
Универсальная программа

Универсальная программа изучения других языков
например C# & Python & C++
переводя каждую строку и абзацы

Графика XONIX Ксоникс kenokeno.ucoz.ru/blog/xonix/2022-10-14-90

Языки и графика и МЫ kenokeno.ucoz.ru/blog/graphic/2022-10-18-91

Интегральное просвещение kenokeno.ucoz.ru/publ/intpro/1-1-0-20

Многие программы kenokeno.ucoz.ru/publ/prog/1-1-0-11

 

Обучение Python
cloud.mail.ru/public/VusB/6tPEgexsv

Обучение C#
cloud.mail.ru/public/p495/7eiY8sbwB

 

Универсальная программа изучения других языков

Изучаются

вывод на экран
ввод с клавиатуры размер массива
массив 1-мерный
массив 2-мерный
случайные
математика
цикл for
условие
цикл while
вывод в файл
считать из файла

и может быть полезна ученикам и учителям

Сценарий:

Стартовать случайные
Задать или ввести с клавиатуры размер массива n
Начать массивы 1-мерный и 2-мерный учитывая n
Начать массивы результатов 1-мерный и 2-мерный

Массив1 случайные от 0 до 9: заполнение и вывод

Если элемент чётный: вычислить квадрат
иначе оставить значение как есть
и результаты поместить в другой массив
и распечатать оба массива в столбик

Сортировка пузырьковая итогового массива
вложенные циклы и обмены

Вывести сортированный итоговый массив через while

Массив 2-мерный заполнить суммами номеров столбца и строки
Если значение нечётное: возвести в квадрат
иначе оставить значение и создать ещё 2-мерный массив
и вывести на экран матрицы исходную и результат

Создать имя файла как 2 случайные цифры и ".txt"

Вывести в файл матрицу результат в обратном порядке
где перевёрнуты и строки и столбцы

Закрыть файл для записи и открыть файл для чтения

Считывать из файла в переменную w
и сформировать на экране матрицу обратную матрицу

Каждый может + должен = обязан
перевести всю программу или часть программы самостоятельно
и лично я перевёл на Python & C# похожие на qb64 qbasic

Randomize Timer: t=timer: n = 3: ' Print "n= ": input n
Dim d(n), a(n, n), x(n), y(n, n) ' universalb.bas

For i = 1 To n: d(i) = Int(Rnd * 9)
Print d(i);: Next: Print: Print

For i = 1 To n
If d(i) Mod 2 = 0 Then x(i)=d(i)^2 Else x(i)=d(i)
Print d(i), x(i): Next: Print

For i = 1 To n - 1: For j = i + 1 To n
    If x(i) > x(j) Then Swap x(i),x(j)
Next: Next

i = 1: While (i <= n)
    Print x(i);: i = i + 1
Wend: Print: Print

For i = 1 To n: For j = 1 To n
    a(i,j) = i + j
    If (a(i,j) Mod 2 <> 0) Then
        y(i,j) = a(i,j)^2
    Else
        y(i,j) = a(i,j)
        End If
Print a(i,j);: Next: Print: Next: Print

For i = 1 To n: For j = 1 To n
Print y(i,j);: Next: Print: Next: Print

a$ = Mid$(Str$(Int(Rnd * 88) + 10) + ".txt", 2, 6)

Open a$ For Output As #1
For i = n To 1 Step -1: For j = n To 1 Step -1
Print #1, y(i,j);: Next: Print #1,: Next: Print #1,

Close: Open a$ For Input As #2

For i = 1 To n: For j = 1 To n
Input #2, w: Print w;: Next: Print: Next: Print
Close

min = d(1): max = d(1):  nmin=1: nmax=1
for i=2 to n
if d(i)< min then min=d(i): nmin=i
if d(i)> max then max=d(i): nmax=i
next
for i=1 to n: Print d(i);: next: Print: Print 
Print min; nmin, max; nmax

s=0: for i=1 to n: s=s+d(i): next: ? s, s/n
_delay .25: Print Timer - t: End

 

Планирую программу qbasic qb64 universe перевести на языки
c# C++ Python JavaScript


Примерный результат при n=3

Universal C#

using System; // universalx.cs
namespace universe { class universe
{ static void Main(string[] args)

{ Random rand = new Random(); int i,j; int n=5;
int[] d = new int[n]; int[] x = new int[n];
int[,] a = new int[n,n]; int[,] y = new int[n,n];

Console.WriteLine("Массив d в строку");
for (i=0; i<n; i++)
{ d[i] = rand.Next(9); Console.Write("{0} ",d[i]);
}

Console.WriteLine("\n \nМассив d чётные x=d^2");
for (i=0; i<n; i++)
  { if (d[i] %2 ==0) x[i] = d[i] * d[i];
    else x[i]=d[i];
Console.WriteLine("{0} {1}", d[i], x[i]);
}

Console.WriteLine("\nМассив x сортировка");
for (i=0; i<n-1; i++) for (j = i+1; j<n; j++)
if (x[i]>x[j]) { var temp=x[i]; x[i]=x[j]; x[j]=temp;}

Console.Write("и вывод x через while\n");
i=0; while (i < n)
       { Console.Write("{0} ",x[i]); i++; }

Console.WriteLine("\n\nМассив y сумма или нечётная y=d^2");
for (i=0; i<n; i++)
  { for (j = 0; j<n; j++)
    { a[i,j]=i+j;
       if (a[i,j] %2 !=0) y[i,j] = a[i,j] * a[i,j];
       else y[i,j] = a[i,j];
Console.Write("{0} ",y[i,j]); }
Console.WriteLine(); }

Console.WriteLine("\nМассив d минимакс от:");
for (i=0; i<n; i++) Console.Write("{0} ", d[i]);
Console.WriteLine("\n");

int min = d[0]; int max = d[0]; int nmin=0; int nmax=0;
for (i=1; i<n; i++)
  { if (d[i]< min) { min=d[i]; nmin=i;}
    if (d[i]> max) { max=d[i]; nmax=i;}
}
Console.WriteLine("{0} {1}   {2} {3}", min, nmin, max, nmax);

Console.WriteLine("\nСумма d и средний");
double s=0; for (i=-1; i<n-1; s += d[++i]);
Console.WriteLine("{0} {1:f2}", s, s/n);

Console.ReadKey();
}}}

 

 

Universal C#

rextester.com/RYGR5556

 

Результат при n=5
Массив d в строку
6 0 7 8 5

Массив d чётные x=d^2
6 36
0 0
7 7
8 64
5 5

Массив x сортировка
и вывод x через while
0 5 7 36 64

Массив y сумма или нечётная y=d^2
 0  1  2  9  4
 1  2  9  4 25
 2  9  4 25  6
 9  4 25  6 49
 4 25  6 49  8


Массив d минимакс от:
6 0 7 8 5

0 1   8 3

Сумма d и средний
26 5,20

 

 

Universal Python

import random # universalp.py
n = 5; d=[1]; a=[1,1]; x=[1]; y=[1,1]

print('Array d in a string')
for i in range (0,n):
    d[i]=d.append(i)
    x[i]=x.append(i)
    d[i] = random.randrange(0,9)
    print (d[i], end=' ')
   
print('\n\nArray d even x=d^2')
for i in range (0,n):
    if d[i] % 2 == 0:
         x[i]=d[i] * d[i]
    else:
         x[i]=d[i]
    print (d[i], x[i], end=' ')
    print()

print('\nArray x sorting')
for i in range (0,n-1):
    for j in range (i+1,n):
       if x[i] > x[j]:
           temp=x[i]
           x[i]=x[j]
           x[j]=temp
     
i=0; print('and output x via while')
while i < n:
    print (x[i], end=' ')
    i=i+1

print('\n\nArray y sum or odd y=d^2')
a=[[i+j for i in range (n)] for j in range (n)]
y=[[i+j for i in range (n)] for j in range (n)]

for i in range (0,n):
    for j in range (0,n):
        if a[i][j] % 2 != 0:
            y[i][j] = a[i][j] * a[i][j]
        print ("%2d" % y[i][j], end=' ')
    print()
print()

dmin = d[1]; dmax = d[1]; nmin=1; nmax=1
for i in range (1,n):
    if d[i]< dmin:
        dmin=d[i]; nmin=i
    if d[i]> dmax:
        dmax=d[i]; nmax=i

print('Array d minimax from:')
for i in range (0,n):
    print (d[i], end=' ')

print ('\n', dmin, nmin, '   ', dmax, nmax, end=' ')

s=0; print('\n\nSum d and average')
for i in range (1,n):
    s=s+d[i]
print(s, s/n, end=' ')

 

 

JavaScript Universal

https://rextester.com/HIQL79958

<!DOCTYPE html> 
<title>UNIVERSAL JavaScript js</title> <html> <body> <noscript>Vkluch JS</noscript>

<script>

var i,j; var n=5; var d=[n],x=[n] // universe.js
document.write("<br/>Massiv d v stroku<br/>")

for (i=0; i<n; i++) 
{ d[i] = Math.floor(Math.random()*9); document.write(d[i]+" ") 
}


document.write("<br/><br/>Massiv d 4etnye x=d^2<br/>")
for (i=0; i<n; i++) 
  { if (d[i] %2 ==0) x[i] = d[i] * d[i];
    else x[i]=d[i];
    document.write(d[i] + "    " + x[i] + "<br/>")
  }


document.write("<br/>Massiv x sorting")
for (i=0; i<n-1; i++) for (j = i+1; j<n; j++) 
if (x[i]>x[j]) { temp=x[i]; x[i]=x[j]; x[j]=temp}

document.write("<br/>i vyvod x 4erez while<br/>")
i=0; while (i < n) { document.write(x[i] + " "); i++}


document.write("<br/><br/>Massiv y summa ili ne4etnaya y=d^2<br/>")

var a=[], y=[] 
for (i=0; i<n; i++) 
   { a[i]=[], y[i]=[]
     for (j=0; j<n; j++) 
         { a[i][j]=i+j 
           if (a[i][j] %2 !=0) y[i][j] = a[i][j] * a[i][j]
           else y[i][j] = a[i][j]
           document.write(y[i][j] + "\t  ") 
         }
      document.write("<br>")
   }


document.write("<br/>Massiv d minimax ot:<br/>")
for (i=0; i<n; i++) document.write(d[i] + " ") 
document.write("<br/>") 


min = d[0]; max = d[0]; nmin=0; nmax=0;
for (i=1; i<n; i++)
  { if (d[i]< min) { min=d[i]; nmin=i;}
    if (d[i]> max) { max=d[i]; nmax=i;}
}
document.write(min + " " + nmin + "   " + max + " " + nmax)


document.write("<br/><br/>Summa d i sredniy<br/>")
s=0; for (i=-1; i<n-1; i++) s += d[++i] 
document.write(s + "  " + s/n + "<br/>")
 
</script>

</body> </html>

 

Universal C++

#include <iostream> // universalc.cpp
using namespace std; int main() // rextester.com/DHHKPJ12975
{ setlocale (LC_ALL, "RUS");
  srand(time(NULL)); int i,j; int n=5;
int d[n], x[n], a[n][n], y[n][n],temp;

cout << "Массив d в строку" << endl;
for (i=0; i<n; i++)
{ d[i] = rand() % 9; cout << d[i] << " ";
}

cout << "\n \nМассив d чётные x=d^2" << endl;
for (i=0; i<n; i++)
  { if (d[i] %2 ==0) x[i] = d[i] * d[i];
    else x[i]=d[i];
cout << d[i] << "  " << x[i] << endl;
}

cout << "\nМассив x сортировка" << endl;
for (i=0; i<n-1; i++) for (j = i+1; j<n; j++)
if (x[i]>x[j]) { temp=x[i]; x[i]=x[j]; x[j]=temp;}

cout << "и вывод x через while\n" << endl;
i=0; while (i < n)
       { cout << x[i] << " "; i++; }

cout << "\n\nМассив y сумма или нечётная y=d^2" << endl;
for (i=0; i<n; i++)
  { for (j = 0; j<n; j++)
    { a[i][j]=i+j;
       if (a[i][j] %2 !=0) y[i][j] = a[i][j] * a[i][j];
       else y[i][j] = a[i][j];
cout << y[i][j] << "\t"; }
cout << endl; }

cout << "\nМассив d минимакс от:" << endl;
for (i=0; i<n; i++) cout << d[i] << " ";
cout << "\n";

int min = d[0]; int max = d[0]; int nmin=0; int nmax=0;
for (i=1; i<n; i++)
  { if (d[i]< min) { min=d[i]; nmin=i;}
    if (d[i]> max) { max=d[i]; nmax=i;}
}
cout << min << " " <<
nmin << "\t"  << max << " " << nmax;

cout << "\n\nСумма d и средний" << endl;
double s=0; for (i=-1; i<n-1; s += d[++i]);
cout << s << "\t" << s/n << "\n";

system("pause");
}

Universal Yabasic: jdoodle.com/ia/CUo
Universal C#: rextester.com/RYGR5556
Universal C++: rextester.com/DHHKPJ12975
Universal JavaScript rextester.com/HIQL79958 jdoodle.com/h/2Uh 
Universal Python: rextester.com/VXCJ24727

 

 

Матрица и файл

Принципиально использую только мои наработки

Синтезировать имя файла как 2 цифры для записи и чтения
в c++ имя файла переменной невозможно или непонятно

Сформировать таблицу умножения до 5*5 в 2-мерный массив

Сохранить таблицу на диск наизнанку начав с "25" =5*5

Считать таблицу в новый 2-мерный массив и вывести на экран

Особенность: qb64 считывает таблицу оформленную в файле
зато для C# & Python сохраняются 25 ячеек в столбик
иначе C# & Python из файла отдельные через табуляции
элементы в таблицу не считывают

Размер кода

Python = 30 строк
qb64 = 15 строк сжато или = 35 строк по 1-й команде
c# = 32 строки сжато или = 55 строк по 1-й команде
c++ = 30 стр сжато или = 45 строк по 1-й команде

Вывод в файл:

qb64 = файл как таблица и читает по 1 между таб
c# & c++ & Python = файл в столбец иначе по 1 не читает

Результат

 1  2  3  4  5
 2  4  6  8 10
 3  6  9 12 15
 4  8 12 16 20
 5 10 15 20 25

25 20 15 10  5
20 16 12  8  4
15 12  9  6  3
10  8  6  4  2
 5  4  3  2  1

 

Matrix C#


C:\Windows\Microsoft.NET\Framework64\v4.0.30319
matrix.bat:

csc.exe /nologo matrix.cs
pause
 

using System; using System.IO; // matrix.cs
namespace matrix { class matrix
{ static void Main(string[] args)

{ Random rand = new Random(); int i,j; int n=5;
int[,] a = new int[n,n]; int[,] y = new int[n,n];
string s = ((10+rand.Next(88)).ToString())+".txt";

for (i=0; i<n; i++)
  { for (j=0; j<n; j++)
    { a[i,j]=(i+1)*(j+1);
      Console.Write("{0}\t",a[i,j]);
    } Console.WriteLine();
  } Console.WriteLine();

var outFile = new StreamWriter(s);

for (i=n-1; i>=0; i--)
  { for (j=n-1; j>=0; j--)
    outFile.WriteLine(a[i,j]);
  } outFile.Close();

var inpFile = new StreamReader(s);

for (i=0; i<n; i++)
  { for (j=0; j<n; j++)
    { y[i,j] = Convert.ToInt32(inpFile.ReadLine());
      Console.Write("{0}\t ",y[i,j]);
    } Console.WriteLine();
  } inpFile.Close();
Console.ReadKey();
}}}

 

Matrix Python

import random # matrix.py
n = 5; a=[1,1]; y=[1,1]

a=[[(i+1)*(j+1) for i in range (n)] for j in range (n)]
y=[[0 for i in range (n)] for j in range (n)]
s = str(random.randrange(10,99))+'.txt'

for i in range (n):
    for j in range (n):
        print ("%2d" % a[i][j], end=' ')
    print()
print()

fw = open(s, 'w')
for i in range (n,0,-1):
    for j in range (n,0,-1):
        fw.write(str(a[i-1][j-1]))
        fw.write('\n')
fw.close()

fr = open(s, 'r')
for i in range (n):
    for j in range (n):
        y[i][j]=fr.readline()
        print ("%2d" % int(y[i][j]), end=' ')
    print()
print()
fr.close()

 

Matrix qb64 qbasic

n = 5: Dim a(n, n), y(n, n) ' matrix.bas
For i = 1 To n: For j = 1 To n
a(i, j) = i * j: Print Using "###"; a(i, j);: Next: Print: Next: Print

a$ = Mid$(Str$(Int(Rnd * 88) + 10) + ".txt", 2, 6)

Open a$ For Output As #1
For i = n To 1 Step -1: For j = n To 1 Step -1
Print #1, a(i, j);: Next: Print #1,: Next: Print #1,

Close: Open a$ For Input As #2

For i = 1 To n: For j = 1 To n
Input #2, y(i, j): Print Using "###"; y(i, j);: Next: Print: Next: Print
Close: end

 

Matrix C++

#include <iostream> // matrix.cpp
#include <fstream>
using namespace std; int main()  
{ setlocale (LC_ALL, "RUS");
  srand(time(NULL)); int i,j; int n=5;
int a[n][n]; int y[n][n];        

for (i=0; i<n; i++)
  { for (j=0; j<n; j++)
    { a[i][j]=(i+1)*(j+1);    
      cout << a[i][j] << "\t";
    } cout << endl;
  } cout << endl;

ofstream fw("54321.txt");

for (i=n-1; i>=0; i--)
  { for (j=n-1; j>=0; j--)
      fw << a[i][j] << "\t";
      fw << endl;
  } fw << endl;
fw.close();

ifstream fr("54321.txt");

for (i=0; i<n; i++)
  { for (j=0; j<n; j++)
    { fr >> y[i][j];
      cout << y[i][j] << "\t";
    } cout << endl;
  } cout << endl;
fr.close();

system("pause");}

 

 

Матрица js JavaScript 

rextester.com/FQF32790

jdoodle.com/h/2Ui

 

<!DOCTYPE html>
<title>MATRIX js JavaScript</title> <html> <body> <noscript>Vkluch JS</noscript>

<script>

var i,j, a=[], y=[]; var n=5; 
document.write("<br>")
for (i=0; i<n; i++)
  { a[i]=[], y[i]=[] 
    for (j=0; j<n; j++)
    { a[i][j]=(i+1)*(j+1);    
      document.write(a[i][j] + " ")
    } document.write("<br>")
  } document.write("<br>")

for (i=n-1; i>=0; i--)
  { for (j=n-1; j>=0; j--)
      document.write(a[i][j] + " ")
      document.write("<br>")
  } document.write("<br>")


</script>

</body> </html>

 


Знакоместо и Ввод и Таймер qb64 qbasic Timer & Cursor & Input

start = Timer ' times.bas
n = 20000
Input "BBEDUTE Enter "; x
For i = n To 0 Step -1
    Locate 5, 5: Print a,
    For j = i + 1 To n: a = i
Next: Next

Locate 8, 8: Print Timer - start
End




Знакоместо и Ввод и Таймер c# Timer & Cursor & Input

using System; using System.IO; // times.cs
namespace times { class times
{ static void Main(string[] args)

{ var start = DateTime.Now;
int i,j,a; int n = 20000;

Console.WriteLine("BBEDUTE Enter ");
string x = Console.ReadLine();

for (i=n; i>=0; i--)
    { Console.SetCursorPosition(5,5);
      Console.Write(i+"  ");
        for (j=i+1; j<n; j++) a=i;
    }
Console.SetCursorPosition(8,8);
Console.Write(DateTime.Now - start);
Console.ReadKey();
}}}
// int x = Convert.ToInt32(Console.ReadLine());





Знакоместо и Ввод и Таймер c++ Timer & Cursor & Input

#include <iostream> // times.cpp
#include <windows.h>
#include <ctime>
using namespace std;
void xy(int x, int y)
 { COORD mesto;
    mesto.X = x; mesto.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), mesto);
 }
int main()
{clock_t t0 = clock();
 cout << "BBEDUTE Digital " << endl;
 string x; cin >> x;
 int n = 10000; int a,i,j;

for (i=n; i>=0; i--)
    { xy(5,5);
      cout << i << "  ";
        for (j=i+1; j<n; j++) a=i;
    }
clock_t t1 = clock();
xy(8,8);
cout << (double)(t1 - t0) / CLOCKS_PER_SEC << endl;
system("pause");
}



Таймер и Ввод Python Timer & Input

import time # times.py
n = 200
print("BBEDUTE Enter ")
x = input()
for i in range (n,0,-1):
    print(i," ")
    for j in range (i):
       a=i 
print(time.perf_counter(), " seconds")

 

 

Universal program for learning other languages
for example C# & Python
translating every line and paragraphs qb64 qbasic

output to screen
keyboard input array size
1-dimensional array
2-dimensional array
random
mathematics
for loop
condition
while loop
output to a file
read from file
and it can be useful to students and teachers

Script:

Start random
Set or enter size of array n from keyboard
Start arrays 1-dimensional and 2-dimensional given n
Start arrays of results 1-dimensional and 2-dimensional

Array 1 random from 0 to 9: filling and output

If element is even: calculate square
otherwise, leave value as it is
and put results in another array
and print both arrays in a column

Bubble sorting of final array
nested loops and exchanges

Output sorted final array via while

Fill 2-dimensional array with sums of column and row numbers
If value is odd: square
it, otherwise leave value and create another 2-dimensional array
and display original matrix and result

Create a file name as 2 random digits and ".txt"

Output result matrix to file in reverse order
where both rows and columns are inverted

Close file for writing and open file for reading

Read from file to variable w
and form a matrix on screen inverse of matrix 2

Everyone can + must = must
translate entire program or part of program independently
and I translated into Python & C# as brothers qb64 qbasic


Universal Python
https://rextester.com/VXCJ24727

Array d in a string
6 0 7 8 5

Array d even x=d^2
6 36
0 0
7 7
8 64
5 5

Array x sorting
and output x via while
0 5 7 36 64

Array y sum or odd y=d^2
 0  1  2  9  4
 1  2  9  4 25
 2  9  4 25  6
 9  4 25  6 49
 4 25  6 49  8


Array d minimax from:
6 0 7 8 5

0 1 8 3

Sum d and average
26 5,20
 

 

 

ФУНКЦИИ  qb64

Программа Функция функций включает: 
корень степень экспонента логарифмы 
тригонометрия и радианы из градусов 
на 5 языках qb64 python c# c++ javascript

Контрольный пример при x=90 y=1322 примерно

qbasic qb64

x = 90 ' funb.bas
y = funb(x)
Print x, y
End

Function funb (x)
    rad = x * pi() / 180
    a = x ^ (1 / 4)
    b = Sqr(x) ': Print b
    c = Cos(rad): Print c
    d = Log(x) ': Print d
    e = Exp(b)
    f = Log(b) * Log(e)

    funb = a + b + c + d + e + f
End Function

 

 

ФУНКЦИИ  Python 
rextester.com/EGXCM83414

import math # funp.py
def funp(x): # rextester.com/EGXCM83414
    rad = x * math.pi / 180
    a = x ** (1 / 4)
    b = x**(1/2) #; print (b)
    c = math.cos(rad); print(c)
    d = math.log10(x) #; print (d)
    e = math.exp(b)
    f = math.log(x,math.exp(1))    
    return a + b + c + d + e + f

x = 90
y = funp(x) 
print(x, y)

 

 

ФУНКЦИИ  C++ 
rextester.com/EKC21250

#include <iostream> // func.cpp
#include <cmath> // rextester.com/EKC21250
using namespace std; 

double func(double x)
{ double rad,a,b,c,d,e,f,func;
    rad = x * M_PI / 180;
    a = pow(x, 1/4);
    b = sqrt(x);  // cout << b << endl;
    c = cos(rad);    cout << c << endl;
    d = log10(x); // cout << d << endl;
    e = exp(b);
    f = log10(b) * log(e);
    func = a + b + c + d + e + f;
    return func;
}

int main()    
{ double x = 90.; 
    cout << x << "     " << func(x) << endl;
    system("pause");
}

 

ФУНКЦИИ  C# 
rextester.com/PYG11940

using System; // funx.cs
namespace funx1 { class funx2 
{ static void Main(string[] args)
{ double x = 90; // rextester.com/PYG11940
    Console.WriteLine("{0}  {1}", x, funx(x));
    Console.ReadKey();
}

public static double funx(double x)
  { double rad,a,b,c,d,e,f,funx;
    rad = x * Math.PI / 180;
    a = Math.Pow (x,1/4);
    b = Math.Sqrt(x);  // Console.WriteLine(b);
    c = Math.Cos(rad);    Console.WriteLine(c);
    d = Math.Log10(x); // Console.WriteLine(d);
    e = Math.Exp(b);
    f = Math.Log10(b) * Math.Log(e);

    return funx = a + b + c + d + e + f;
  }
}}

 

ФУНКЦИИ JavaScript JS 


rextester.com/HIQL79958

jdoodle.com/h/2Uj

<!DOCTYPE html>
<title>FUNJ JavaScript</title> <noscript>Vkluch JS</noscript>

<script>

function funj(x) 
{   rad = x * Math.PI / 180
    a = Math.pow(x, 1/4)
    b = Math.sqrt(x);  // document.write(b)
    c = Math.cos(rad);    document.write(c)
    d = Math.log10(x); // document.write(d)
    e = Math.exp(b)
    f = Math.log10(b) * Math.log(e)
    funj = a + b + c + d + e + f
    return funj
}

x = 90 
document.write(x + "\t")
document.write("\n" + funj(x))

</script>

</body> </html>

 

 

Матрица сортировка строки и столбцы отдельно 

Недавно на форуме решалась задача про 2-мерный массив на c++
и далее создал алгоритм сортирующий раздельно столбцы и строки
и далее за минуты перевёл из c++ на python

применив для 2-х массивов заполнение и расширение см. в начале
a=[[random.randrange(0,9) for i in range (m)] for j in range (n)]

Однако хотя по логике должны быть циклы i=n & j=m
почему в начале работают наоборот циклы i=m & j=n

Программа создаёт 2-мерный массив
и сортирует раздельно столбцы и строки


Python
rextester.com/LVIB34467

import random # matrixsortp.py
n=3; m=5; a=[1,1]; b=[1,1]
a=[[random.randrange(0,9) for i in range (m)] for j in range (n)]
b=[[1 for i in range (m)] for j in range (n)]

for i in range (n):
    for j in range (m):
        print ("%2d" % a[i][j], end=' ')
        b[i][j]=a[i][j]
    print()
print()

for i in range (n):
    for j in range (m-1):
        for k in range (j+1,m):
           if (a[i][j]>a[i][k]):
               t=a[i][j]; a[i][j]=a[i][k]; a[i][k]=t;

for i in range (n):
    for j in range (m):
        print ("%2d" % a[i][j], end=' ')
    print()
print()

for i in range (n):
    for j in range (m):
        print ("%2d" % b[i][j], end=' ')
    print()
print()

for j in range (m):
    for i in range (n-1):
        for k in range (i+1,n):
            if (b[i][j]>b[k][j]):
               t=b[i][j]; b[i][j]=b[k][j]; b[k][j]=t;

for i in range (n):
    for j in range (m):
        print ("%2d" % b[i][j], end=' ')
    print()


 2  6  3  6  0 
 8  5  0  6  7 
 8  5  2  1  1 

 0  2  3  6  6 
 0  5  6  7  8 
 1  1  2  5  8 

 2  6  3  6  0 
 8  5  0  6  7 
 8  5  2  1  1 

 2  5  0  1  0 
 8  5  2  6  1 
 8  6  3  6  7 

 

 

C#
rextester.com/JSYB65969

using System; // matrixsortx.cs
namespace matrixsort
{ class matrixsort
{ static void Main(string[] args)

{ Random rand = new Random(); int i,j,k,t; int n=3, m=5; 
  int[,] a = new int[n,m]; int[,] b = new int[n,m];

for (i=0; i<n; i++)
  { for (j=0; j<m; j++)
    { a[i,j] = rand.Next(9); b[i,j]=a[i,j];
        Console.Write(a[i,j]+" ");       
    } Console.WriteLine();
  }
Console.WriteLine();

for (i=0; i<n; i++)
  for (j=0; j<m-1; j++)
    for (k=j+1; k<m; k++)
      if (a[i,j]>a[i,k]) { t=a[i,j]; a[i,j]=a[i,k]; a[i,k]=t;}

for (i=0; i<n; i++)
  { for (j=0; j<m; j++) Console.Write(a[i,j]+" ");
        Console.WriteLine();
  }
Console.WriteLine();

for (i=0; i<n; i++)
  { for (j=0; j<m; j++) Console.Write(b[i,j]+" ");
        Console.WriteLine();
  }
Console.WriteLine();

for (j=0; j<m; j++)
  for (i=0; i<n-1; i++)
    for (k=i+1; k<n; k++)
      if (b[i,j]>b[k,j]) { t=b[i,j]; b[i,j]=b[k,j]; b[k,j]=t;}

for (i=0; i<n; i++)
  { for (j=0; j<m; j++) Console.Write(b[i,j]+" ");
        Console.WriteLine();
  }
Console.WriteLine();
Console.ReadKey();
}}}

 


QB64

n=3: m=5 ' matrixsortb.bas
Dim a(n,m),b(n,m):

For i=1 To n: For j=1 To m
    a(i,j)=Int(Rnd*9): b(i,j)=a(i,j)
    Print a(i,j);
Next: Print: Next: Print

For i=1 To n: For j=1 To m-1
    For k=j + 1 To m
If (a(i,j) > a(i,k)) Then t=a(i,j): a(i,j)=a(i,k): a(i,k)=t
Next: Next: Next

For i=1 To n: For j=1 To m
    Print a(i,j);
Next: Print: Next: Print
  
For i=1 To n: For j=1 To m
    Print b(i,j);
Next: Print: Next: Print

For j=1 To m: For i=1 To n-1
    For k=i + 1 To n
If (b(i,j) > b(k,j)) Then t=b(i,j): b(i,j)=b(k,j): b(k,j)=t
Next: Next: Next

For i=1 To n: For j=1 To m
    Print b(i,j);
Next: Print: Next: Print
End

 

 

C++ rextester.com/OVFK93608

#include <iostream> // matrixsort.cpp
using namespace std; int main() // rextester.com/OVFK93608
{ setlocale (LC_ALL, "RUS");
  srand(time(NULL)); int i,j,k,t; 
  int n=3, m=5; int a[n][m], b[n][m];

for (i=0; i<n; i++)
  { for (j=0; j<m; j++)
    { a[i][j]= rand() % 9; b[i][j]=a[i][j];
      cout << a[i][j] << "\t"; }
      cout << endl; 
    }
cout << endl;

for (i=0; i<n; i++)
  for (j=0; j<m-1; j++)
    for (k=j+1; k<m; k++)
      if (a[i][j]>a[i][k]) { t=a[i][j]; a[i][j]=a[i][k]; a[i][k]=t;}
      
for (i=0; i<n; i++)
  { for (j=0; j<m; j++) cout << a[i][j] << "\t"; 
    cout << endl;
  } 
cout << endl;
 
for (i=0; i<n; i++)
  { for (j=0; j<m; j++) cout << b[i][j] << "\t"; 
    cout << endl;
  } 
cout << endl;

for (j=0; j<m; j++)
  for (i=0; i<n-1; i++)
    for (k=i+1; k<n; k++)
      if (b[i][j]>b[k][j]) { t=b[i][j]; b[i][j]=b[k][j]; b[k][j]=t;}
 
for (i=0; i<n; i++)
  { for (j=0; j<m; j++) cout << b[i][j] << "\t"; 
    cout << endl;
  } 
cout << endl;
system("pause");
}

 

MatrixSort JavaScript JS 

jdoodle.com/h/2UB

<!DOCTYPE html>
<title>MATRIX sort FUN js JavaScript</title> 
<html> <body> <noscript>Vkluch JS</noscript>

jdoodle.com/h/2UB

<script>

var i,j,k, a=[], b=[], c=[]; var n=3, m=5; 
document.write("<br><br>")

for (i=0; i<n; i++)
  { a[i]=[], b[i]=[] 
    for (j=0; j<m; j++)
    { a[i][j]=Math.floor(Math.random()*9)
      b[i][j]=a[i][j]; 
      document.write(a[i][j] + " ")
    } document.write("<br>")
  } document.write("<br>")

for (j=0; j<m; j++)
    { c[j]=[] 
      for (i=0; i<n; i++)
        c[j][i]=b[i][j]
    }

for (i=0; i<n; i++) a[i] = a[i].sort() 
 
for (i=0; i<n; i++)
  { for (j=0; j<m; j++)
    { document.write(a[i][j] + " ")
    } document.write("<br>")
  } document.write("<br>")

for (i=0; i<n; i++)
  { for (j=0; j<m; j++)
    { document.write(b[i][j] + " ")
    } document.write("<br>")
  } document.write("<br>")

for (j=0; j<m; j++) c[j] = c[j].sort() 

for (i=0; i<n; i++)
    for (j=0; j<m; j++)
        b[i][j] = c[j][i]

for (i=0; i<n; i++)
  { for (j=0; j<m; j++)
    { document.write(b[i][j] + " ")
    } document.write("<br>")
  } document.write("<br>")

</script>

</body> </html>

 

 

trinket.io/python/286485b49b

 

Викторина сортирует вопросы и внутри вопросов варианты 
чтобы пользователь вопросы и ответы по порядку не запомнил 
 

jdoodle.com/h/2Up

 

<!DOCTYPE html>
<title>OPROS js JavaScript</title> 
<html> <body> <noscript>Vkluch JS</noscript>

https://jdoodle.com/h/2Up

<script>

var i,j,p,k,c,d,t; var n=3, m=5, k=2*n*m; var a=[]
document.write("<br>")

document.write("<br>BOIIPOCbI & OTBETbI<br><br>")

for (i=1; i<=n; i++)
  { a[i]=[]; a[i][1]=i*111
    document.write(a[i][1] + " ")

       for (j=2; j<=m; j++)
       { a[i][j]=i*10+j
         document.write(a[i][j] + " ")
       } document.write("<br>")
  } 

document.write("<br>COPT OTBETbI<br><br>")

for (i=1; i<=n; i++)
for (j=2; j<=m; j++)
{ c = 2 + Math.floor(Math.random()*(m-1))
  d = 2 + Math.floor(Math.random()*(m-1))
     t=a[i][c]; a[i][c]=a[i][d]; a[i][d]=t;    
}

for (i=1; i<=n; i++)
{ for (j=1; j<=m; j++)
    { document.write(a[i][j] + " ")
    } document.write("<br>")

document.write("<br>COPT BOIIPOCbI<br><br>")

for (i=1; i<=n; i++)
{ c = 1 + Math.floor(Math.random()*n)
  d = 1 + Math.floor(Math.random()*n)

for (j=1; j<=m; j++)
    {t=a[c][j]; a[c][j]=a[d][j]; a[d][j]=t;
    }
}

for (i=1; i<=n; i++)
{ for (j=1; j<=m; j++)
    { document.write(a[i][j] + " ")
    } document.write("<br>")
} document.write("<br>")


</script>

</body> </html>


222 22 21 24 25 23
333 35 34 32 31 33
111 15 13 12 11 14

 

import random; n=5; m=7; k=2*n*m; a=[1,1]; # oprosp.py
a=[[1 for i in range (m+1)] for j in range (n+1)]

# rextester.com/HTWE97215

print("Вопросы и Ответы")
for i in range (1,n+1):
   a[i][1]=i*111
   print(a[i][1], end=' ')

   for j in range (2,m+1):
      a[i][j]=i*10+j
      print(a[i][j], end=' ')
   print()
print()

print("Сорт Ответы")
for i in range (1,n+1):
    for j in range (2,m+1):
        c = 2 + random.randrange(0,m-1)
        d = 2 + random.randrange(0,m-1)
        t=a[i][c]; a[i][c]=a[i][d]; a[i][d]=t

for i in range (1,n+1):
    for j in range (1,m+1):
       print(a[i][j], end=' ')
    print()
print()

print("Сорт Вопросы")
for i in range (1,n+1):
    c = 1 + random.randrange(0,n)
    d = 1 + random.randrange(0,n)

    for j in range (1,m+1):
        t=a[c][j]; a[c][j]=a[d][j]; a[d][j]=t

for i in range (1,n+1):
    for j in range (1,m+1):
       print(a[i][j], end=' ')
    print()
print()

 

Массивы оформление

qbasic         dim a(n,m): a(i,j)=1

c#               int[,] a = new int[n,m]; a[i,j]=1 

c++             int a[n][m]; a[i][j]=1

javascript     a=[]; for(i=0;i<n;i++) a[i]=[]; a[i][j]=1

python         a=[1,1]; a=[[0 for i in range (m)] for j in range (n)]; a[i][j]=1
 

 

Просмотров: 153 | Добавил: DANILIN | Рейтинг: 0.0/0
Всего комментариев: 0

Форма входа

Поиск

Календарь

«  Октябрь 2022  »
ПнВтСрЧтПтСбВс
     12
3456789
10111213141516
17181920212223
24252627282930
31

Статистика


Онлайн всего: 1
Гостей: 1
Пользователей: 0
Карта мира

Данный сайт средством массовой информации не является.
Данный сайт: личный дневник, созданный в развлекательных целях.
Данный сайт азартные игры не пропагандирует и не организует.
Данный сайт ставки не принимает и выигрыши не выплачивает.
Данный сайт никакие платные услуги не предоставляет.

Сайт и автор за упущенную выгоду ответственность не несёт.
Сайт и автор за возможные убытки ответственность не несёт.

Файлы имеют цель: приоритет открытий, изобретений, формул и творчества
и тексты выражают субъективные оценочные суждения без упоминания имён.

На сайте никакие иностранные агенты не упоминаются.

Все тексты юридической силы не имеют и служить доказательством в суде не могут.
Все формулы возможно вывести самостоятельно и ответ автора сайта не нужен.
18+ web.archive.org/web/20230602152617///kenokeno.ucoz.ru/load/?page2

This site is not a media outlet.
This site: personal diary created for entertainment purposes.
This site promote does not and gambling not organize.
This site bets does not accept and winnings does not pay out.
This site any paid does services not provide.

Site and author for lost profits are not responsible.
Site and author for possible losses are not responsible.

Files have a target: priority of discoveries, inventions, formulas, and creativity
and texts express subjective value judgments without mentioning any names.

On this site none foreign agents don't mentioned.

All texts have no legal force and as evidence in court cannot serve.
All formulas can be deduced independently & response of site author is not required.
18+ web.archive.org/web/20230602154543///kenokeno.ucoz.ru/publ/?page2

Бесплатный конструктор сайтов - uCozЯндекс.Метрика