1
已解决
蔡辰夕
新手启示者
新手启示者
1、输出自定义类
#include <iostream>
using namespace std;
class MyData
{
public:
string a, b, c;
public:
MyData(string a, string b, string c) : a(a), b(b), c(c) {};
};
ostream& operator << (ostream& os, const MyData& my_data)
{
os << my_data.a << " " << my_data.b << " " << my_data.c;
return os;
}
int main()
{
MyData Hbh("Hello", ",", "world!");
cout << Hbh << endl;
return 0;
}
蔡辰夕在2023-08-25 12:02:45追加了内容
2、超级鬼畜!!!
#include <iostream>
using namespace std;
string f(int seed) {
ᅠ ᅠ srand(seed);
ᅠ ᅠ string s;
ᅠ ᅠ while (true) {
ᅠ ᅠ ᅠ ᅠ int n = rand() % 20;
ᅠ ᅠ ᅠ ᅠ if (n == 15) break;
ᅠ ᅠ ᅠ ᅠ s.push_back((char) (n + 100));
ᅠ ᅠ }
ᅠ ᅠ return s;
}
int main() {
ᅠ ᅠ cout << f(41488932) + " " + f(24081743);
ᅠ ᅠ return 0;
}
蔡辰夕在2023-08-25 12:12:16追加了内容
3、宏YYDS!
#include <stdio.h>
#define Say(sth) puts(#sth)
int main(){
return Say(Hello world!);
}
4、断章取义!!!
#include <stdio.h>
int main(){
return puts(&”Do not say: Hello world!”[12]);
}
5、话分两头的helloworld
#include <iostream>
// 本文转自 C++Builder研究 – http://www.ccrun.com/article.asp?i=999&d=v433i2
class say
{
public:
say()
{
std::cout << "Hell";
}
~say()
{
std::cout <<"world!";
}
}hello;
int main()
{
std::cout << "o ";
return 0;
}
6、罕见做法
#include <iostream>
template <char * words>
class say
{
public:
void operator () ()
{
std::cout << words;
}
};
extern char hello[] = ”Hello world!”;
int main()
{
return say<hello>()(), 0;
}
蔡辰夕在2023-08-25 12:14:20追加了内容
7、外星人语言!
#include <stdio.h>
void alien_say(char * p){
while (putchar(*(p += *(p + 1) – *p)));
}
int main(){
return alien_say(“BETHO! Altec oh liryom(a loadjudas!) dowd.”), 0;
}
0
已采纳
薛乘志
初级启示者
初级启示者
你这还是不行
#include <stdio.h>
int main(int argc, char *argv[])
{
return argv ? main(0, 0) : (argc < 14 ? putchar("Gdkkn+\x1fvnqkc \t"[argc] + 1), main(argc + 1, 0) : 0);
}
0
0
0
陶春光
中级守护
中级守护
0
0
0
0
0
0
0
0
0