fork download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. template<typename T>
  7. bool is_bigger(T* arr, size_t size) {
  8. return all_of(arr+1,arr+size,[](T& elem){return *(&elem-1)<elem;});
  9. }
  10.  
  11. bool is_bigger(char *str) {
  12. return is_bigger(str,strlen(str));
  13. }
  14.  
  15. int main() {
  16. int a[]={1,4,6,8};
  17. int b[]={1,4,6,3};
  18. char c[] = "abceghopqr";
  19. char d[] = "abceghfxyz";
  20. float e[] = {1.0,7.9,32.3,1e6};
  21. if(is_bigger(a,sizeof(a)/sizeof(a[0]))){
  22. cout <<"A"<<endl;
  23. }
  24. if(is_bigger(b,sizeof(b)/sizeof(b[0]))){
  25. cout <<"B"<<endl;
  26. }
  27. if(is_bigger(c)){
  28. cout <<"C"<<endl;
  29. }
  30. if(is_bigger(d)){
  31. cout <<"D"<<endl;
  32. }
  33. cout<< "BONUS: ";
  34. if(is_bigger(e,sizeof(e)/sizeof(e[0]))){
  35. cout <<"E"<<endl;
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
A
C
BONUS: E