2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,15 @@
with Ada.Text_IO, Ada.Integer_Text_IO;
procedure User_Input is
I : Integer;
begin
Ada.Text_IO.Put ("Enter a string: ");
declare
S : String := Ada.Text_IO.Get_Line;
begin
Ada.Text_IO.Put_Line (S);
end;
Ada.Text_IO.Put ("Enter an integer: ");
Ada.Integer_Text_IO.Get(I);
Ada.Text_IO.Put_Line (Integer'Image(I));
end User_Input;

View file

@ -0,0 +1,18 @@
with
Ada.Text_IO,
Ada.Integer_Text_IO,
Ada.Strings.Unbounded,
Ada.Text_IO.Unbounded_IO;
procedure User_Input2 is
S : Ada.Strings.Unbounded.Unbounded_String;
I : Integer;
begin
Ada.Text_IO.Put("Enter a string: ");
S := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Text_IO.Get_Line);
Ada.Text_IO.Put_Line(Ada.Strings.Unbounded.To_String(S));
Ada.Text_IO.Unbounded_IO.Put_Line(S);
Ada.Text_IO.Put("Enter an integer: ");
Ada.Integer_Text_IO.Get(I);
Ada.Text_IO.Put_Line(Integer'Image(I));
end User_Input2;

View file

@ -0,0 +1,8 @@
#import system.
#import extensions.
#symbol program =
[
#var num := console write:"Enter an integer: " readLine:(Integer new).
#var word := console write:"Enter a String: " readLine.
].

View file

@ -0,0 +1,2 @@
printf("String:"); string_value := readline();
printf("Integer: "); int_value := parse(readline());

View file

@ -0,0 +1,32 @@
use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
.trim()
.parse()
.unwrap_or_else(|e| exit_err(&e, 2));
println!("You entered: {}", n);
}
fn grab_input(msg: &str) -> io::Result<String> {
let mut buf = String::new();
print!("{}: ", msg);
try!(io::stdout().flush());
try!(io::stdin().read_line(&mut buf));
Ok(buf)
}
fn exit_err<T: Display>(msg: T, code: i32) -> ! {
let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
process::exit(code)
}