Uses crt;
var a,b: Integer;
Begin
Write('Введите целое число: ');
Read a;
While a>0 do
Begin
b:=b+a mod 10;
a:=a div 10;
End;
Writeln('Сумма цифр введённого числа равна ', b);
End.
11 девочек м 10 мальчиков.
<span>1011= 1*2^3+0*2^2+1*2^1+1*2^0=8+0+2+1=11
</span>1010= 1*2^3+0*2^2+1*2^1+0*2^0=8+0+2+0=10
Program Frank;
const n=20;
TYPE mas=array[1..n] of integer;
var a:mas;i:integer;
begin
for i:=1 to n do begin
a[i]:=sqr(i);
write(' ',a[i]);
end;
end.
В паскале попробывал все получилось)
var
a,b,c,e:integer;
begin
read(a);
c:=0;
for e:=1 to a
do
begin
read(b);
if b mod 10=3
then
c:=c+1;
end;
write(c);
end.
#include <iostream>
#include <cstdlib>
#include <ctime>
int main()
{
using namespace std;
cout << "Enter size of array: ";
int N;
cin >> N;
int * ARR = new int[N];
srand(time(0));
int i;
for (i = 0; i < N; ++i)
ARR[i] = rand() % 100 + 1;
cout << "Here is an original array:\n";
for (i = 0; i < N; ++i)
cout << ARR[i] << " ";
cout << endl;
int temp = ARR[N - 1];
for (i = N - 1; i > 0; --i)
ARR[i] = ARR[i - 1];
ARR[0] = temp;
cout << "\nHere is a new array:\n";
for (i = 0; i < N; ++i)
cout << ARR[i] << " ";
cout << endl;
return 0;
}