filename: everyother.h #pragma once #include <iostream> #include <vector> #include <sstream> #include <initializer_list> using std::initializer_list; using std::vector; using std::ostream; using std::cout; template<typename T> class EveryOther; template<typename TRead more
filename: everyother.h
#pragma once
#include <iostream>
#include <vector>
#include <sstream>
#include <initializer_list>
using std::initializer_list;
using std::vector;
using std::ostream;
using std::cout;
template<typename T>
class EveryOther;
template<typename T>
ostream & operator<<(ostream & o, const EveryOther<T>& e);
template <class T>
class EveryOther{
public:
vector<T>vec_;
EveryOther()=default;
EveryOther(initializer_list<T> c): vec_(c){};
void push_back(T var){
vec_.push_back(var);
}
int size(){
vector<T>vec1;
for(size_t i = 0; i < vec_.size(); i+=2){
vec1.push_back(vec_[i]);
}
return vec1.size();
}
friend ostream & operator<< <T>(ostream &, const EveryOther&);
};
template<typename T>
ostream & operator<<(ostream & o,const EveryOther<T>& e){
o << "EveryOther(";
for(size_t i = 0; i < e.vec_.size(); i+=2){
o << e.vec_[i] << ", ";
}
o << ')';
return o;
}
# function that sort the list by the course namedef sortByCourse(lst, course):# if the course is CSEif(course == "CSE110"):return sorted(lst, key = lambda l: l[1], reverse = True)# if the course is PHYif(course == "PHY110"):return sorted(lst, key = lambda l: l[2], reverse = True)# if the course is MRead more
# function that sort the list by the course name def sortByCourse(lst, course): # if the course is CSE if(course == "CSE110"): return sorted(lst, key = lambda l: l[1], reverse = True) # if the course is PHY if(course == "PHY110"): return sorted(lst, key = lambda l: l[2], reverse = True) # if the course is MAT if(course == "MAT110"): return sorted(lst, key = lambda l: l[3], reverse = True)
lst = [["Alan", 95, 87, 91], ["Turing", 92, 90, 83], ["Elon", 87, 92, 80], ["Musk", 85, 94, 90]] # take course name as input course = input() # sort the list using fucntion sortedList = sortByCourse(lst, course) # print final result for c in sortedList: print(c[0])
Which data structure is used for implementing recursion?
Correct Option is (c.) Stack .
Correct Option is (c.) Stack .
See lessThe memory address of the first element of an array is called?
Correct option to the question 'The memory address of the first element of an array is called' is D. base address
Correct option to the question ‘The memory address of the first element of an array is called’ is D. base address
See lessWrite a templated class named “EveryOther” that behaves much like …
filename: everyother.h #pragma once #include <iostream> #include <vector> #include <sstream> #include <initializer_list> using std::initializer_list; using std::vector; using std::ostream; using std::cout; template<typename T> class EveryOther; template<typename TRead more
filename: everyother.h
filename: main.cpp
Output EveryOther(include, keep, )
See lessSuppose a list contains marks earned in the courses CSE110, …
# function that sort the list by the course namedef sortByCourse(lst, course):# if the course is CSEif(course == "CSE110"):return sorted(lst, key = lambda l: l[1], reverse = True)# if the course is PHYif(course == "PHY110"):return sorted(lst, key = lambda l: l[2], reverse = True)# if the course is MRead more
If g(z) is the tanh function, which of the following is the correct expression for its derivative with respect to z
Correct Answer: d. 1 – g(z)2
Correct Answer: d. 1 – g(z)2
See lessCan blockchain help in maintaining medical records?
Answer: a. Yes
Answer: a. Yes
See less