accelerated c++ 0章 练习解答

本文通过多个示例展示了C++的基本语法特性,包括简单的输出语句、字符串处理、转义字符的应用及程序结构等。文章适合初学者理解C++的基础用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

0-0:

#include<iostream>

int main(){
 std::cout << "hello,world" << std::endl;
 return 0;
}

 

0-1: 3+4; 是一个表达式语句,会执行3+4,结果7将放在一个临时变量里. 这个表达式没什么意义~~.

 

0-2:

#include<iostream>

int main(){
 std::cout << "This (*) is aquote, and this (//) is a backslash." << std::endl;
 return 0;
}

ps: /" = " , /' = ' , // = / ;

 

0-3:

#include<iostream>

int main(){
 std::cout << "********" << std::endl;
 std::cout << "/ta" <<std::endl;
 return 0;
}

/t 占8个字符宽

 

0-4:

#include<iostream>

int main(){
 std::cout << "#include<iostream>" << std::endl << "int main(){" << std::endl << "std::cout << /"hello,world/" << std::endl;" << std::endl << "return 0;" << std::endl << "}" << std::endl;
}

 

0-5: 不正确 少了 {} 和 return .

 

0-6;VC6下能运行 抱一个警告.

 

0-7; 不正确 /* 注释牵套了. 导致一部注释没被包含.

 

0-8;正确 //后的所以内容都被注释掉了

 

0-9; int main(){}

 

0-10;#include<iostream>

int
main(){
 std::cout
  <<
  "hello,world"
  <<
  std::endl;
 return
  0;
}
运行正常.

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值