//перевод числа из системы исчисления
//с основанием от 2 до 9 в десятичную
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
int pss(char sr[80], int i, int osn)
{
static int s;
char ch=sr[i-1];
if (i==strlen(sr)) s=1;
s=s*osn;
if (1<i) return (atoi(&ch)+pss(sr,i-1,osn)*osn);
else return (atoi(&ch));
}
int main(int argc, char** argv)
{
int osn=0;
char st[80];
cout<<" задайте основание (от 2 до 9) ";
cin>>osn; cout<<endl;
cout<<"число: "; cin>>st; cout<<endl;
cout<<"в десятичной системе: "
<<pss(st,strlen(st),osn);
return(0);
}
<span>
</span>
Var
a,b,r:byte;
begin
randomize;
a:=Random(9)+1;
b:=Random(9)+1;
Write(a,' x ',b,' = ');
Readln(r);
if r=a*b then Writeln('Правильно!')
else Writeln('Вы ошиблись. Верный результат ',a*b)
end.
В первом варианте приходится закрашивать лишь мелкие треугольники
во втором же заливается все кроме них
Static void Main(string[] args)
{
int count = 0;
Console.Write("Введите размерность массива: ");
int n = Convert.ToInt32(Console.ReadLine());
int[] mas = new int[n];
Console.WriteLine("Заполните массив: ");
for (int i = 0; i < n; i++)
{
Console.Write("\t{0} элемент массива: ", i + 1);
mas[i] = Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < n; i++)
if (mas[i] > 0 && mas[i] \% 2 == 0)
count++;
Console.WriteLine("Из {0} элементов массива {1} элементов являются положительными четными",n,count);
Console.WriteLine("{0}\% элементов являются положительными четными", (double)count/n*100);
Console.ReadLine();
}