AC++第零章

第零章的题目很简单,入门性质,基本是个人都能写出来。。。

0-1 计算3+4的值,但不输出。

0-2 源代码:

#include <iostream>

int main()

{

std::cout<<"This (\") is a quote , and  this (\\) is a backslash."

<<std::endl;

return 0;

}

0-3 "\t"代表输出" ".如"This (\") is a quote ,\tand  this (\\) is a backslash."

This (") is a quote , and  this (\) is a backslash

0-4 源代码:

#include <iostream>

using namespace std;

int main()

{

cout<<"include<iostream>"<<endl;

cout<<"using namespace std;"<<endl;

cout<<"int main()"<<endl;

cout<<"{"<<endl;

cout<<"cout<<\"hello world!\"<<endl;"<<endl;

cout<<"return 0;"<<endl;

cout<<"}"<<endl;

return 0;

}


0-5 不是,因为main函数没有定义。会出现句法错误。

0-6 是一个有效程序,运行结果为:Hello, world!

0-7 注释错误,因为注释符号/*和*/在C++编译器中不支持嵌套,所以只能识别第一个/*和第一个*/符号,后面的汉子字符不作为注释部分,无法识别。

0-8 有效。//符号为对行注释,不存在嵌套问题。

0-9 源代码:int main(){}

0-10 源代码:

#include <iostream>

int 

main

(

)

{

std

::

cout

<<

"Hello world!"

<<

std

::

endl

;

return 

0

;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值