Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6. template<class T>
  7. int IleWPrzedziale(T *tab,int n,T p1,T p2){
  8.     int count =0;
  9.     for(int i=0; i<n;i++){
  10.         if(tab[i]>=p1 && tab[i]<=p2){
  11.             count++;
  12.         }
  13.     }
  14.     return count;
  15. }
  16.  
  17. int main()
  18. {
  19.     int tabInt[5]={1,2,3,4,5};
  20.     int p1 = 2;
  21.     int p2 = 4;
  22.  
  23.     cout<<"W przedziale jest : "<<IleWPrzedziale<int>(tabInt,5,p1,p2)<<" liczb"<<endl;
  24.     int jednocyfrowe =0;
  25.     int dwucyfrowe =0;
  26.     int inne =0;
  27.    
  28.     int t1[200];
  29.     for(int i=0;i<200;i++){
  30.         t1[i]=i+1;
  31.     }
  32.    
  33.     for(int i=0 ;i<200;i++){
  34.         if(to_string( t1[i] ).lenght() == 1){
  35.             jednocyfrowe++;
  36.         }else if(to_string( t1[i] ).lenght() == 2){
  37.             dwucyfrowe++;
  38.         }else{
  39.             inne++;
  40.         }
  41.     }
  42.  
  43.     cout<<"Licz jednocyfrowych: "<<jednocyfrowe<<" Dwucyfrowych: "<<dwucyfrowe<<" O wiekszej ilosci cyfr"<<inne<< endline;
  44.  
  45.     system("PAUSE");
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement