#include <bits/stdc++.h>
using namespace std;
int search1(string str) {
for (int i = 0; i < str.size(); i++) {
if (str[i] == 'f') return i;
}
return -1;
int search2(string str) {
for (int i = str.size() - 1; i >= 0; i--) {
int main() {
string str = {};
getline(cin, str);
int a = search1(str);
int b = search2(str);
if (a != -1) {
if (a == b)
cout << a;
else
cout << a << " " << b;
return 0;
128₁₀ = 10000000₂
164₁₀ = 10100100₂
177₁₀ = 10110001₂
125₁₀ = 1111101₂
215₁₀ = 11010111₂
247₁₀ = 11110111₂
Объяснение:
128₁₀ = 0*2⁰ + 0*2¹ + 0*2² + 0*2³ + 0*2⁴ + 0*2⁵ + 0*2⁶ + 1*2⁷ = 10000000₂
164₁₀ = 0*2⁰ + 0*2¹ + 1*2² + 0*2³ + 0*2⁴ + 1*2⁵ + 0*2⁶ + 1*2⁷ = 10100100₂
177₁₀ = 1*2⁰ + 0*2¹ + 0*2² + 0*2³ + 1*2⁴ + 1*2⁵ + 0*2⁶ + 1*2⁷ = 10110001₂
125₁₀ = 1*2⁰ + 0*2¹ + 1*2² + 1*2³ + 1*2⁴ + 1*2⁵ + 1*2⁶ = 1111101₂
215₁₀ = 1*2⁰ + 1*2¹ + 1*2² + 0*2³ + 1*2⁴ + 0*2⁵ + 1*2⁶ + 1*2⁷ = 11010111₂
247₁₀ = 1*2⁰ + 1*2¹ + 1*2² + 0*2³ + 1*2⁴ + 1*2⁵ + 1*2⁶ + 1*2⁷ = 11110111₂
#include <bits/stdc++.h>
using namespace std;
int search1(string str) {
for (int i = 0; i < str.size(); i++) {
if (str[i] == 'f') return i;
}
return -1;
}
int search2(string str) {
for (int i = str.size() - 1; i >= 0; i--) {
if (str[i] == 'f') return i;
}
return -1;
}
int main() {
string str = {};
getline(cin, str);
int a = search1(str);
int b = search2(str);
if (a != -1) {
if (a == b)
cout << a;
else
cout << a << " " << b;
}
return 0;
}
128₁₀ = 10000000₂
164₁₀ = 10100100₂
177₁₀ = 10110001₂
125₁₀ = 1111101₂
215₁₀ = 11010111₂
247₁₀ = 11110111₂
Объяснение:
128₁₀ = 0*2⁰ + 0*2¹ + 0*2² + 0*2³ + 0*2⁴ + 0*2⁵ + 0*2⁶ + 1*2⁷ = 10000000₂
164₁₀ = 0*2⁰ + 0*2¹ + 1*2² + 0*2³ + 0*2⁴ + 1*2⁵ + 0*2⁶ + 1*2⁷ = 10100100₂
177₁₀ = 1*2⁰ + 0*2¹ + 0*2² + 0*2³ + 1*2⁴ + 1*2⁵ + 0*2⁶ + 1*2⁷ = 10110001₂
125₁₀ = 1*2⁰ + 0*2¹ + 1*2² + 1*2³ + 1*2⁴ + 1*2⁵ + 1*2⁶ = 1111101₂
215₁₀ = 1*2⁰ + 1*2¹ + 1*2² + 0*2³ + 1*2⁴ + 0*2⁵ + 1*2⁶ + 1*2⁷ = 11010111₂
247₁₀ = 1*2⁰ + 1*2¹ + 1*2² + 0*2³ + 1*2⁴ + 1*2⁵ + 1*2⁶ + 1*2⁷ = 11110111₂