Advertisement
bozhilov

Odd Even - NOSYNCDEV

Nov 24th, 2022
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. f = open("main.cpp", "w")
  2. f.write("""
  3. #include <iostream>
  4.  
  5. int main() {
  6.    int x;
  7.    std::cout << "Enter a number: "<<std::endl;
  8.    std::cin >> x;
  9.  
  10.    if(x == 0){
  11.        std::cout << "Number is even";
  12.    }
  13. """) # opening statement
  14. for x in range(1, 1000):
  15.     odd_string = "odd" if x % 2 != 0 else "even"
  16.     string_to_write = f"\telse if(x == {x}){{\n\t\tstd::cout << \"Number is {odd_string}\" << std::endl;\n\t}}\n"
  17.     f.write(string_to_write)
  18.  
  19. f.write("}\n")
  20.  
  21. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement