ajutați- mă va rog dau 100 de puncte!
Răspunsuri la întrebare
Răspuns:
145. #include <iostream>
using namespace std;
int main()
{
int n, a, b, cnt, i;
cnt = 0;
cin >> n >> a;
for(i = 1; i < n; i++) {
cin >> b;
if(a == b) {
cnt++;
}
a = b;
}
cout << cnt;
return 0;
}
146. #include <iostream>
using namespace std;
int main()
{
int n, a, b, cb, i, cnt, nrca, nrcb;
cnt = 0;
cin >> n >> a;
for(i = 1; i < n; i++) {
cin >> b;
nrca = 0;
nrcb = 0;
while(a > 0) {
nrca+=a%10;
a = a/10;
}
cb = b;
while(b > 0) {
nrcb+=b%10;
b = b/10;
}
if(nrca == nrcb) {
cnt++;
}
a = cb;
}
cout << cnt;
return 0;
}
147. #include <iostream>
using namespace std;
int main()
{
int n, a, b, cb, i, cnt, nrca, nrcb;
cnt = 0;
cin >> n >> a;
for(i = 1; i < n; i++) {
cin >> b;
nrca = 0;
nrcb = 0;
while(a > 0) {
if(a%10%2 == 0)
nrca++;
a = a/10;
}
cb = b;
while(b > 0) {
if(b%10%2 == 0)
nrcb++;
b = b/10;
}
if(nrca == nrcb) {
cnt++;
}
a = cb;
}
cout << cnt;
return 0;
}
148. #include <iostream>
using namespace std;
int main()
{
int n, a, b, c, i, cnt;
cnt = 0;
cin >> n >> a >> b;
for(i = 2; i < n; i++) {
cin >> c;
if(a == b+c || b == a+c || c == a+b) {
cnt++;
}
a = b;
b = c;
}
cout << cnt;
return 0;
}
149. #include <iostream>
using namespace std;
int main()
{
int n, a, b, c, i, cnt;
cnt = 0;
cin >> n >> a >> b;
for(i = 2; i < n; i++) {
cin >> c;
if(a*a == b*b+c*c || b*b == a*a+c*c || c*c == a*a+b*b) {
cnt++;
}
a = b;
b = c;
}
cout << cnt;
return 0;
}
150. #include <iostream>
using namespace std;
int main()
{
int n, a, b, i, cnt, maxi;
cnt = 0;
maxi = 0;
cin >> n >> a;
if(a % 2 == 0) {
cnt++;
}
for(i = 1; i < n; i++) {
cin >> b;
if(b % 2 == 0) {
cnt++;
} else {
if(cnt > maxi) {
maxi = cnt;
cnt = 0;
}
}
a = b;
}
if(cnt > maxi) {
maxi = cnt;
cnt = 0;
}
cout << maxi;
return 0;
}
Explicație:
Sper ca te-am ajutat :)