Number / 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
$ ./test abcd mismatched. $ ./test pass matched. $
#include <stdio.h> #include <string.h> int main() { char s[16] = ""; char p[16] = "pass"; /* 02を参照:gets()は推奨されない */ gets(s); if (strcmp(s, p)) { printf("mismatched.\n"); } else { printf("matched.\n"); } return 0; }
#include <iostream> #include <string> int main() { std::string s=""; const std::string ps = "pass"; std::cin >> s; if (s == ps) { std::cout << "matched." << std::endl; } else { std::cout << "mismatched." << std::endl; } return 0; }
import java.io.*; class Main { public static void main(String[] args) { final String p = "pass"; try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String s = reader.readLine(); if (s.equals(p)) { System.out.println("matched."); } else { System.out.println("mismatched."); } } catch (IOException e) { e.printStackTrace(); } } }
my $p = "pass"; chomp(my $s = <STDIN>); if ($s eq $p) { print"matched.\n"; } else { print"mismatched.\n"; }
P = "pass" s = gets.chomp if s == P puts "matched." else puts "mismatched." end
最終更新日 : 2004.08.23
Number / 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
copyright 2000-2005
ARGIUS project