Guest User

Untitled

a guest
Sep 14th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. rj "data.json" users => print "hello, {$}!"
  2.  
  3. ----
  4.  
  5. let fs = require("fs")
  6. let {users} = JSON.parse(fs.readFileSync("data.json","utf-8"))
  7. for(let user of users) console.log(`hello, ${user}`)
  8.  
  9. ----------------------------------
  10.  
  11. serve 3000
  12. * "get" "/" { req res | res send "hello" }
  13.  
  14. ----
  15.  
  16. const express = require('express')
  17. const app = express()
  18.  
  19. app.get('/', function (req, res) {
  20. res.send('Hello World')
  21. })
  22.  
  23. app.listen(3000)
  24.  
  25. --------------------------------------
  26. - r rnd 100
  27. =>
  28. read
  29. > r ? print "слишком большое число"
  30. < r ? print "слишком маленькой число"
  31. == r ? print "браво"; exit
  32.  
  33. ----
  34.  
  35. use rand::Rng;
  36. use std::cmp::Ordering;
  37. use std::io;
  38.  
  39. fn main() {
  40. println!("Guess the number!");
  41.  
  42. let secret_number = rand::thread_rng().gen_range(1..=100);
  43.  
  44. loop {
  45. println!("Please input your guess.");
  46.  
  47. let mut guess = String::new();
  48.  
  49. io::stdin()
  50. .read_line(&mut guess)
  51. .expect("Failed to read line");
  52.  
  53. let guess: u32 = match guess.trim().parse() {
  54. Ok(num) => num,
  55. Err(_) => continue,
  56. };
  57.  
  58. println!("You guessed: {guess}");
  59.  
  60. match guess.cmp(&secret_number) {
  61. Ordering::Less => println!("Too small!"),
  62. Ordering::Greater => println!("Too big!"),
  63. Ordering::Equal => {
  64. println!("You win!");
  65. break;
  66. }
  67. }
  68. }
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment