fork download
  1. #ifndef STRUCT07_H_
  2. #define STRUCT07_H_
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. struct complex_number {
  8. double real;
  9. double imaginary;
  10. };
  11.  
  12. istream& operator>>(istream& is, complex_number& cpx);
  13.  
  14. enum complex_type{
  15. real,
  16. imaginary
  17. };
  18.  
  19. struct Query{
  20. complex_type type;
  21. int index;
  22. };
  23.  
  24. class Judge{
  25. public:
  26. void check_init(){
  27. if(init == 0){
  28. cout << "Please call the init function first!" << endl;
  29. exit(0);
  30. }
  31. }
  32. void init_f(int &N, int &Q, complex_number*& cpx, Query*& queries){
  33. cin >> N >> Q;
  34. cpx = new complex_number[N];
  35. queries = new Query[Q];
  36. for(int i = 0; i < N; i++){
  37. cin >> cpx[i];
  38. }
  39. for(int i = 0; i < Q; i++){
  40. int tp;
  41. cin >> queries[i].index >> tp;
  42. if(tp) queries[i].type = imaginary;
  43. else queries[i].type = real;
  44. }
  45. init = 1;
  46. }
  47. private:
  48. int init = 0;
  49. };
  50.  
  51. Judge j;
  52.  
  53. void Init(int &N, int &Q, complex_number*& cpx, Query*& queries){
  54. j.init_f(N, Q, cpx, queries);
  55. }
  56.  
  57. void Answer(double ans){
  58. j.check_init();
  59. cout << ans << endl;
  60. }
  61. #endif // STRUCT07_H_
  62.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty