0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paiza×Qiita記事投稿キャンペーン「プログラミング問題をやってみて書いたコードを投稿しよう!」
https://qiita.com/official-events/9ab96aa95d62fe3cbdd7

初心者向けDランク〜最難関Sランクまで全25問(すべて無料)
https://paiza.jp/pages/campaign/paiza-qiita

足し算 (paizaランク D 相当)
https://paiza.jp/works/mondai/d_rank_skillcheck_sample/addition/edit?language_uid=c-plus-plus

足し算 (paizaランク D 相当) C++(53)
https://qiita.com/kaizen_nagoya/items/3b3eb9dcc6577f001551

標準で用意されていた

sample.rs
// 自分の得意な言語で
// Let's チャレンジ!!
fn main(){
  println!("XXXXXX");
}

手を加えた

add.rs
//
// add.rs (c) Dr. Kiyoshi Ogawa
use std::io;
fn main(){
  println!("%d", 1,231 + 5,178);
}

コード実行結果: 実行結果ステータス compilation error
コンパイル時エラーメッセージ

error
error: multiple unused formatting arguments
 --> Main.rs:5:18
  |
5 |   println!("%d", 1,231 + 5,178);
  |            ----  ^ ^^^^^^^ ^^^ argument never used
  |            ||    | |
  |            ||    | argument never used
  |            ||    argument never used
  |            |help: format specifiers use curly braces: `{}`
  |            multiple missing formatting specifiers
  |
  = note: printf formatting is not supported; see the documentation for `std::fmt`

warning: unused import: `std::io`
 --> Main.rs:3:5
  |
3 | use std::io;
  |     ^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: aborting due to previous error; 1 warning emitted
add2.rs
//
// add.rs (c) Dr. Kiyoshi Ogawa
use std::io;
fn main(){
  println!({}", 1,231 + 5,178);
}
error

>コード実行結果 実行結果ステータス	compilation error
コンパイル時エラーメッセージ	
```rust:error
error: unknown start of token: \u{201d}
 --> Main.rs:5:12
  |
5 |   println!({}", 1,231 + 5,178);
  |            ^
  |
help: Unicode character '”' (Right Double Quotation Mark) looks like '"' (Quotation Mark), but it is not
  |
5 |   println!("{}", 1,231 + 5,178);
  |            ~

error[E0765]: unterminated double quote string
 --> Main.rs:5:15
  |
5 |     println!({}", 1,231 + 5,178);
  |  _______________^
6 | | }
  | |__^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0765`.

提出コードのアウトプット
期待する出力 6409

add3.rs
// https://qiita.com/kaizen_nagoya/items/224571e58eedc624e87c
// add3.rs (c) Dr. Kiyoshi Ogawa
use std::io::stdin;
fn main(){
iny i;
  println!("{i}", i=(1,231 + 5,178));
}


error
>コード実行結果 実行結果ステータス	compilation error
コンパイル時エラーメッセージ	
```rust:error
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `i`
 --> Main.rs:5:5
  |
5 | iny i;
  |     ^ expected one of 8 possible tokens

warning: unused import: `std::io::stdin`
 --> Main.rs:3:5
  |
3 | use std::io::stdin;
  |     ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: aborting due to previous error; 1 warning emitted

提出コードのアウトプット
期待する出力
6409

add4.rs
// https://qiita.com/kaizen_nagoya/items/224571e58eedc624e87c
// add.rs (c) Dr. Kiyoshi Ogawa
use std::io::stdin;
fn main(){
int i;
  println!("{i}", i=(1,231 + 5,178));
}



error
>コード実行結果 
実行結果ステータス	compilation error
コンパイル時エラーメッセージ	

error: expected one of !, ., ::, ;, ?, {, }, or an operator, found i
--> Main.rs:5:5
|
5 | int i;
| ^ expected one of 8 possible tokens

warning: unused import: std::io::stdin
--> Main.rs:3:5
|
3 | use std::flag_io::stdin;
| ^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

error: aborting due to previous error; 1 warning emitted

>提出コードのアウトプット	
期待する出力	
6409





# reference
[Rust] 文字列のフォーマット指定(println! / format!)
https://qiita.com/YusukeHosonuma/items/13142ab1518ccab425f4

色んな言語を標準入出力で繋ぐ(5*8種類)
https://qiita.com/uesseu/items/e94dd058bfec8ddc355f
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?