Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int f(int x, int k){
- int nr = 0;
- while(x){
- if(x % 10 == k)
- nr++;
- x /= 10;
- }
- if(nr)
- return true;
- else
- return false;
- }
- int main()
- {
- int k, v[ 1000 ], i = 0, nr = 0, s = 0, r = 0; //s si r pt media aritmetica //nr e nr de numere citite //k e cifra aia data
- cin >> k;
- cin >> v[ i ];
- while(v[ i ]){
- cin >> v[ i + 1]; nr++; i++;
- }
- for(int i = 0; i < nr; i++)
- if((v[ i ] > 99 && v[ i ] < 1000) && (f( v[ i ], k ) == true)){
- s += v[ i ]; r++;}
- cout << float(s/r);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement