Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rj "data.json" users => print "hello, {$}!"
- ----
- let fs = require("fs")
- let {users} = JSON.parse(fs.readFileSync("data.json","utf-8"))
- for(let user of users) console.log(`hello, ${user}`)
- ----------------------------------
- serve 3000
- * "get" "/" { req res | res send "hello" }
- ----
- const express = require('express')
- const app = express()
- app.get('/', function (req, res) {
- res.send('Hello World')
- })
- app.listen(3000)
- --------------------------------------
- - r rnd 100
- =>
- read
- > r ? print "слишком большое число"
- < r ? print "слишком маленькой число"
- == r ? print "браво"; exit
- ----
- use rand::Rng;
- use std::cmp::Ordering;
- use std::io;
- fn main() {
- println!("Guess the number!");
- let secret_number = rand::thread_rng().gen_range(1..=100);
- loop {
- println!("Please input your guess.");
- let mut guess = String::new();
- io::stdin()
- .read_line(&mut guess)
- .expect("Failed to read line");
- let guess: u32 = match guess.trim().parse() {
- Ok(num) => num,
- Err(_) => continue,
- };
- println!("You guessed: {guess}");
- match guess.cmp(&secret_number) {
- Ordering::Less => println!("Too small!"),
- Ordering::Greater => println!("Too big!"),
- Ordering::Equal => {
- println!("You win!");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment