we2的输入 (++ C+十 4+十 ++ 例1:输入/输出运算符<<和>的应用 #include <iostream. h> void minot int x56, y =10 float a char *str =Windows" 结果:123.45 cin > a 5610 cout < endl 123.45 cout < endl Windows cout < str < end
例1:输入/输出运算符<< 和 >>的应用 #include <iostream.h> void main( ) { int x=56, y=10; float a; char *str ="Windows"; cin >> a; cout << x << y << endl; cout << a << endl; cout << str << endl; } 结果:123.45 56 10 123.45 Windows §10.2 一般的输入/输出
毫嘉2般然的输入 例2:输入/输出流的应用 #include <iostream. h> void main(i X,y) char c cout < Enter two integers cin>>X>>y; cout IS not)<< equal to"<<y<< endl c= cin. get();∥从键盘输入一字符 cout. pi ut(c);∥从八屏幕输出一字符 结果: Enter two integers:75 7 is not equal to 5 A A
例2:输入/输出流的应用 #include <iostream.h> void main( ) { int x, y; char c; cout << "Enter two integers:" cin >> x >> y; cout << x << (x==y? " is": " is not ") << " equal to" << y << endl; c=cin.get( ); //从键盘输入一字符 cout.put(c); //从屏幕输出一字符 } 结果:Enter two integers: 7 5 7 is not equal to 5 A A §10.2 一般的输入/输出