当前位置:   article > 正文

【洛谷B2002】Hello,World!_c++洛谷b2022

c++洛谷b2022

本文为新手学习C++的练习记录


题目

题目描述

编写一个能够输出 Hello,World! 的程序。

提示:

  • 使用英文标点符号;
  • Hello,World! 逗号后面没有空格。
  • HW大写字母。

输入格式

输出格式

样例 #1

样例输入 #1

  • 1

样例输出 #1

Hello,World!
  • 1

解答

#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    printf("Hello,World!");
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

或者

#include <iostream>
using namespace std;
int main(){
    cout << "Hello,World!";
    return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

printf()和cout的区别

在上面两种方法中,分别用了printf()cout,两者的区别在于

(不好意思,有点没看懂网上的解答)
  • 1

那就随便点吧,感觉就是

coutprintf()用处更大,但是在很简单的情况下,cout要比printf()复杂一点。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/877733
推荐阅读
相关标签
  

闽ICP备14008679号