Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.cpp
- * Author: undefiened
- *
- * Created on 24 Май 2012 г., 21:48
- */
- #include <cstdlib>
- #include <iostream>
- #include "time.h"
- using namespace std;
- /*
- *
- */
- void initiliase_array(int n, float *arr){
- for(int i = 0; i<n; i++){
- *(arr+i) = rand()%10000;
- *(arr+i) /= 100;
- cout<<*(arr+i)<<" ";
- }
- }
- int elems_less_then_k(float *arr, float k, int n){
- int counter = 0;
- for(int i = 0; i<n; i++){
- if(*(arr+i)<k){
- counter++;
- }
- }
- return counter;
- }
- int main(int argc, char** argv) {
- srand(time(NULL));
- float A[10];
- float B[30];
- float min;
- int count = 0;
- cout<<"Заполним массив А"<<endl;
- initiliase_array(10,A);
- cout<<endl<<"Заполним массив В"<<endl;
- initiliase_array(30, B);
- cout<<endl<<"Минимум массива А = ";
- min = A[0];
- for(int i = 0; i<10; i++){
- if(A[i]<min){
- min = A[i];
- }
- }
- cout<<min<<endl;
- count = elems_less_then_k(B,min,30);
- if(count==0){
- cout<<"Нет таких элементов"<<endl;
- } else {
- cout<<"Есть "<<count<<" элементов, меньших "<<min<<endl;
- }
- }
Add Comment
Please, Sign In to add comment