4094
Объяснение:
Function newstr1(str As String, n As Integer) As String
Dim i As Integer
For i = 1 To n
str = Replace(str, "A", "BC")
str = Replace(str, "B", "AC")
str = Replace(str, "CC", "AD")
Next
newstr1 = str
End Function
Function chrcount(str1 As String, str2 As String) As Integer
Dim str() As String
str = Split(str1, str2)
chrcount = UBound(str, 1)
=chrcount(newstr1("AA";11);"D")
Excel VBA
P.S.
Для номера процедуры равного i, количество символов "D" вычисляется по формуле D(i)=2*2^i-2
#include <iostream>
#include <cmath>
using namespace std;
signed main()
{
setlocale(LC_ALL, "Rus");
int N;
bool haveZero = false, haveOne = false;
cin >> N;
N = abs(N);
while(N>0){
if(N % 10 == 0)
haveZero = true;
if(N % 10 == 1)
haveOne = true;
N /= 10;
}
cout << "Наличие нуля: " << boolalpha << haveZero << endl;
cout << "Наличие единицы в числе: " << boolalpha << haveOne << endl;
return 0;
4094
Объяснение:
Function newstr1(str As String, n As Integer) As String
Dim i As Integer
For i = 1 To n
str = Replace(str, "A", "BC")
str = Replace(str, "B", "AC")
str = Replace(str, "CC", "AD")
Next
newstr1 = str
End Function
Function chrcount(str1 As String, str2 As String) As Integer
Dim str() As String
str = Split(str1, str2)
chrcount = UBound(str, 1)
End Function
=chrcount(newstr1("AA";11);"D")
Excel VBA
P.S.
Для номера процедуры равного i, количество символов "D" вычисляется по формуле D(i)=2*2^i-2
#include <iostream>
#include <cmath>
using namespace std;
signed main()
{
setlocale(LC_ALL, "Rus");
int N;
bool haveZero = false, haveOne = false;
cin >> N;
N = abs(N);
while(N>0){
if(N % 10 == 0)
haveZero = true;
if(N % 10 == 1)
haveOne = true;
N /= 10;
}
cout << "Наличие нуля: " << boolalpha << haveZero << endl;
cout << "Наличие единицы в числе: " << boolalpha << haveOne << endl;
return 0;
}