1 Java Language2//Package Main3//be careful not to add the package name, or you will get an error. 4 5 ImportJava.io.*;6 ImportJava.util.*;7 Cin.hasnext ();8 cin.hasnextline ();9 cin.hasnextbigdecimal ();Ten Cin.hasnextbiginteger (); One Cin.hasnextboolean (); A cin.hasnextbyte (); - cin.hasnextdouble (); - cin.hasnextint (); the Cin.hasnextlong (); -PublicclassTest { - Public static void Main (String args[]) - { +Scanner cin = new Scanner (System.inch); - int A, b; + while(Cin.hasnextint ())//determine if there is a value in CIN A { atA =cin.nextint (); -b =cin.nextint (); -System.out.println (A +b); - } - } - } in Public static void Main (String args[]) - { toint X=1; +int y=~1; -System.out.println (integer.tobinarystring (x));//1 theSystem.out.println (integer.tobinarystring (y));//1111111111111111111111111110 *System.out.println (y);//-2 $ }Panax Notoginseng*Test 3: Reading data from a text file -*/ the static void TestExample03 () { +1, open a character stream object in memory to read the file A Try { theReader reader=new FileReader ("E:/readme.log"); + -//read a loop, one at a time $int ch=Reader.read (); $StringBuffer buffer=new StringBuffer (); - while(Ch!=-1) { //Read Success - Buffer.append ((char) ch); theCh=Reader.read (); - }Wuyi System.out.println (buffer.tostring ()); the3, close the stream - reader.close (); Wu } catch (FileNotFoundException e) { -System.out.println ("the file to be read does not exist:"+e.getmessage ()); About } catch (IOException e) { $System.out.println ("file read error:"+e.getmessage ()); - } - } -/** A*Test 4: Write data to a text file +*/ the static void TestExample04 () { -System.out.println ("Please enter the content:"); $String text=Input.next (); the Try { the1, open the stream theWriter w=new FileWriter ("e:/test. txt", true); the2, write content - w.write (text); in3, close the stream the w.close (); the } catch (IOException e) { AboutSystem.out.println ("File Write error:"+e.getmessage ()); the } the } the #!/usr/bin/env python + #Coding=utf-8 - #Python uses 2.7, indents can use tab, 4 spaces, or 2 spaces, but only one can be selected, not a variety of mixing the while1:BayiA=[] thes =raw_input () the #raw_input () do not have any information - ifs! ="": - forXinchs.split (): the a.append (int (x)) the the Printsum (a) the Else: - Break the the//C language the #include <iostream.h>//Data flow input/output94 #include <math.h>//define Mathematical functions the #include <stdio.h>//define input/output functions the #include <stdlib.h>//define miscellaneous functions and memory allocation functions the #include <string.h>//String processing98 #include <stdio.h> About int main () - {101 int A, b;102 while(SCANF ("%d%d", &a, &b)! =EOF)103printf"%d\n", A +b);104System"Pause"); the }106 107 108C++language109 #include <iostream> the using namespace std;111 int main () the {113 int A, b; the while(Cin>> a >>b) thecout << A + b <<Endl; the return0;117 }118 119 - introduce the input control of 1:java121Test 2: Test output x=1 and y=~1122 Test 3: Reading data from a text file123Test 4: Write data to a text file
Simple java,python,c,c++.