4 solutions

  • 7
    @ 2025-7-9 9:11:06

    这道题是一道基础题!!

    在 C++ 中,"Hello, World!" 程序是学习这门语言的经典入门示例,它展示了 C++ 程序的基本结构和输出功能。下面是具体实现及详细讲解:

    这里有三种做法:

    1正常输出

    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
    	cout << "Hello,World!";
    	return 0;
    }
    

    2最短输出

    #include<cstdio>
    main(){printf("Hello,World!");}
    

    3字符串做法

    #define NDEBUG
    #import <bits/stdc++.h>
    #ifdef __linux__
    #endif
    using namespace std;
    using std::cin, std::cout;
    using i64 = signed long long;
    #define false 0
    typedef signed long long IntPtr;
    IntPtr i;
    
    main(i64) {
    #ifdef __linux__
    	std::ios(false), cin.tie(nullptr), cout.tie(nullptr);
    	ios::sync_with_stdio(0);
    	cin.tie(nullptr);
    	char s[12] = {'h', 'e', 'l', 'l', 'o', ',', 'w', 'o', 'r', 'l', 'd', '!'};
    	for (i = 0; i < 12; ++i) {
    		if (i == 0 || i == 6) {
    			if (s[i] >= 'a' && s[i] <= 'z') {
    				s[i] -= 32;
    			}
    		}
    	}
    
    	for (i = 0; i < 12; i++) {
    		if (i == 5) {
    			cout << s[i];
    		} else {
    			cout << s[i];
    		}
    	}
    
    	cout << endl;
    #endif
    	return false;
    }
    
    

    4字符瞎做法

    #define NDEBUG
    #import <bits/stdc++.h>
    #ifdef __linux__
    #endif
    using namespace std;
    using std::cin, std::cout;
    using i64 = signed long long;
    #define false 0
    typedef signed long long IntPtr;
    IntPtr n;
    
    main(i64) {
    #ifdef __linux__
    #endif
    	std::ios(false), cin.tie(nullptr), cout.tie(nullptr);
    	ios::sync_with_stdio(0);
    	cin.tie(nullptr);
    
    	char a[] = "Hello,World!";
    	int b = 0, c = 0, d = 0, e = 0;
    	i64 f = 0, g = 0, h = 0, i = 0;
    
    	while (b < 1) {
    		for (c = 0; c < 1; c++) {
    
    			do {
    				if (d < 12) {
    					while (e == 0) {
    						if (a[d] != '\0') {
    							std::cout << a[d];
    							e = 1;
    						} else {
    							e = 1;
    						}
    					}
    
    					e = 0;
    					d++;
    				} else {
    					break;
    				}
    			} while (d < 12);
    		}
    
    		for (f = 0; f < 5; f++) {
    
    			if (f % 2 == 0) {
    				g = f + 1;
    			} else {
    				g = f - 1;
    			}
    
    			while (h < g) {
    				if (h == 2) {
    					i = 1;
    				} else {
    					i = 0;
    				}
    
    				h++;
    			}
    
    			h = 0;
    		}
    
    		b++;
    	}
    
    	i64 j = 0;
    
    	while (j < 10) {
    		if (j > 5) {
    			j += 2;
    		} else {
    			j++;
    		}
    
    		for (i64 k = 0; k < j; k++) {
    
    			if (k == j / 2) {
    				i64 l = k * 2;
    			}
    		}
    	}
    
    	i64 m = 5;
    
    	do {
    		if (m % 3 == 0) {
    			m--;
    		} else {
    			m = m - 2;
    		}
    	} while (m > 0);
    
    
    	return false;
    }
    

Information

ID
11909
Time
1000ms
Memory
128MiB
Difficulty
1
Tags
# Submissions
168
Accepted
58
Uploaded By