helloworld
--------------------------------------------
直接输入和输出到文件
---------------------------------
#include <iostream>
using namespace std ;
int main ()
{
int a , b;
cout << " Please input two numbers :";
cin >> a >> b;
cout << a << "+" << b << "=" << a + b << endl ;
return 0;
}
--------------------------------------------
直接输入和输出到文件
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("sum.in");
ofstream fout ("sum.out ");
int main ()
{
int a , b;
fin >> a >> b;
fout << a + b << endl ;
return 0;
}
---------------------------------
#include <stdio.h>
union {
int a [2];
double b;
char c [8];
} x;
int main ()
{
x.c [0] = 'G';
x.c [1] = 'O';
x.c [2] = 'O';
x.c [3] = 'D';
x.c [4] = 'B';
x.c [5] = 'A';
x.c [6] = 'B';
x.c [7] = 'Y';
printf ("int : %d byte (s)\n" , sizeof (int ));
printf (" double : %d byte (s)\n" , sizeof ( double ));
printf (" char : %d byte (s)\n" , sizeof ( char ));
// printf (" bool : %d bytes (s)\n" , sizeof ( bool ));
printf ("\n");
printf (" integer : %d %d\n" , x.a[0] , x.a [1]);
printf (" real number : %e\n" , x.b);
printf (" characters : %c%c%c%c%c%c%c%c\n" , x.c[0] , x.c[1] , x.c[2] ,
x.c[3] , x.c[4] , x.c[5] , x.c[6] , x.c [7]);
printf ("HEX : %X%X%X%X%X%X%X%X\n" , x.c[0] , x.c[1] , x.c[2] , x.c[3] ,
x.c[4] , x.c[5] , x.c[6] , x.c [7]);
return 0;
}
~