1.
// ,
int main()
{
return 0; // 0
}
( )
#include <cstdio> // getchar()
int main()
{
// ( )
getchar();
return 0;
}
------------------------------------------------------------------------
2.
// ( )
// - \
#include <cstdio>
int main()
{
puts(" Hello "); // - ( puts <iostream>)
getchar();
return 0;
}
( ᒺ std)
#include <iostream>
using namespace std; // i cout(), endl(\n)
int main()
{
cout << " Hello, Students " << endl; //
cin.get();
return 0;
}
------------------------------------------------------------------------
3.
// (
// buffer[32] )
// (gets puts)
#include <cstdio>
int main()
{
// 80
char buffer[32];
// ,
gets( buffer );
//
puts ("Your input is: ");
puts (buffer);
// gets
gets( buffer );
return 0;
}
------------------------------------------------------------------------
// ᒺ string
#include <string>
#include <iostream>
using namespace std;
int main()
{
// ,
string myname;
//
cout << " Please, your name sir: ";
// (cin) myname
cin >> myname;
// ( )
cout << " Hello, dear " << myname << endl;
cin.get();
cin.get();
return 0;
}
4.
------------------------------------------------------------------------
// while
# include <iostream>
using namespace std;
int main()
{
char s[80] = "abracadabra";
int i = 0;
// false
while (s[i])
{
cout << s[i];
i++;
}
cin.get();
cin.get();
return 0;
;
}
------------------------------------------------------------------------
// for
# include <iostream>
using namespace std;
|
|
int main()
{
string s = "abracadabra";
for (int i= 0; i<=s.length(); i++)
{
cout << s[i]; //
}
cin.get();
return 0;
}
------------------------------------------------------------------------
//
# include <iostream>
using namespace std;
int main()
{
// s ( )
char *s = "abracadabra";
while (*s)
{
cout << *s;
s++; // s ( )
}
cin.get();
return 0;
}
5.
------------------------------------------------------------------------
//
# include <iostream>
#include <cstdlib>
//
# include <conio.h>
using namespace std;
int main()
{
char sym; //
do {
sym = getch(); //
cout<<sym; //
} while (sym!=char(13)); // ENTER
cout << endl; // -
cin.get();
return 0;
}