Subiectul I
1. Raspuns c.
2. a) 46402
b) 1040, 1041, 1050, 1051, 1140, 1141, 1150, 1151
c)
citeste n (numar natural) m <- 0 p <- 1 executa | daca n%2 != 0 | | n = n - 1 | . | m <- m + (n%10)*p | n <- [n/10] | p <- p*10 .cat timp n>0 scrie md)
#include <iostream>
using namespace std;
int main() {
int n, p, m = 0;
cin >> n;
p = 1;
while (n) {
if (n % 2 != 0) {
n = n - 1;
}
m = m + (n % 10) * p;
n = n / 10;
p = p * 10;
}
cout << m;
return 0;
}
Subiectul II
1. b
2. b
3.
float a = s.A.x - s.B.x; float b = s.A.y - s.B.y; float rezultat = a*a + b*b;
4.
for (i = 1; i <= 5; i++) for (j = 1; j <= 5; j++) A[i][j] = (i + j) % 5;
5.
#include <iostream>
using namespace std;
int main() {
char a[30], b[30];
cin >> a;
cin >> b;
int as = strlen(a);
int bs = strlen(b);
for (int i = as - 1; i >= 0; i--) {
for (int j = i; j < as; j++) {
int k = 0;
while (k < bs && j < as && a[j] == b[k]) {
cout << a[j];
k++;
j++;
}
}
cout << "\n";
}
}
Subiectul III
1. b
2. 94*2*1*0
Niciun comentariu:
Trimiteți un comentariu