3
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ラーニングレベルアップ問題集の「Eメールアドレス」を色々な言語でやってみた

Last updated at Posted at 2024-08-12

paiza×Qiita記事投稿キャンペーンということで、paizaラーニングレベルアップ問題集のEメールアドレスを色々な言語でやってみました。対象はコードモンスター大図鑑で対応している9言語です。

2024/08/24追記
Perl, Scala, Go, Swiftの4言語を追加いたしました。


方針
  • ローカル部$s$を受け取る。
  • ドメイン$t$を受け取る。
  • ローカル部とドメインから以下の構文に沿った文字列を出力する。
    s(ローカル部)@t(ドメイン)

PHP
<?php
	$s = trim(fgets(STDIN));
	$t = trim(fgets(STDIN));
	echo "$s@$t\n";
?>

Ruby
s = gets.chomp
t = gets.chomp
print "#{s}@#{t}\n"

Java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
  		sc.close();
		System.out.println(s + "@" + t);
	}
}

Python
s = input()
t = input()
print(s + "@" + t)

C言語
#include <stdio.h>
int main(void){
	char s[65];
	scanf("%s", s);
	char t[65];
	scanf("%s", t);
	printf("%s@%s\n", s, t);
	return 0;
}

C#
using System;

class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
		string t = Console.ReadLine();
		Console.WriteLine(s + "@" + t);
	}
}

Javascript
const lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
const s = lines[0];
const t = lines[1];
console.log(s + "@" + t);

C++
#include <iostream>
using namespace std;

int main(void){
	string s;
	cin >> s;
	string t;
	cin >> t;
	cout << s << "@" << t << endl;
	return 0;
}

Kotlin
fun main() {
	val s = readLine()
	val t = readLine()
	println(s + "@" + t)
}

Perl
chomp(my $s = <STDIN>);
chomp(my $t = <STDIN>);
print $s , "@" , $t , "\n";

Scala
import scala.io.StdIn._

object Main extends App{
    val s = readLine()
    val t = readLine()
	println(s + "@" + t)
}

Go
package main
import "fmt"
func main() {
	var s string
	fmt.Scan(&s)
	var t string
	fmt.Scan(&t)
    fmt.Println(s + "@" + t)
}

Swift
import Foundation

let s = readLine()!
let t = readLine()!
print(s + "@" + t)
3
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
3
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?