Guest User

Untitled

a guest
Aug 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. # # # # # # # #
  2. #!/usr/bin/env ruby
  3. # # # # # # #
  4.  
  5. # # # # # #
  6. # Created January 28th 2018
  7. # Copyright (c) 2017 Beyar N.
  8. # # # #
  9.  
  10. # # #
  11. # Name: count.rb
  12. # #
  13.  
  14. # System methods
  15. class Sys
  16. def Sys::cls
  17. system "clear" or system "cls"
  18. end
  19. def Sys::cmd(input)
  20. system(input)
  21. end
  22. end
  23.  
  24. # Source code
  25. source = '#include <stdio.h>
  26. int main(){
  27. int counter;
  28. for(counter = 0; counter < 1000001; counter++){
  29. printf("%d\n", counter);
  30. }
  31. }'.split("\n").to_a
  32.  
  33. # Creates & inserts the code
  34. srcfile = File.new("tempfile.c", "w+")
  35. for each in source
  36. srcfile.puts(each)
  37. end
  38. srcfile.close
  39.  
  40. # Run and destroy
  41. Sys.cmd("gcc tempfile.c -o tempfile -O2")
  42. Sys.cmd("rm tempfile.c")
  43. Sys.cmd("./tempfile")
  44. Sys.cmd("rm tempfile")
Add Comment
Please, Sign In to add comment