注册 登录
编程论坛 C++教室

点点滴滴的比较

hmsabc 发布于 2010-08-19 16:12, 545 次点击
程序代码:

#include "stdafx.h"
#include <iostream>
using namespace System;

int main(array<System::String ^> ^args)
{
    int apples,oranges;
    int fruit;

    apples = 5; oranges = 6;
    fruit = apples  + oranges;
   
    Console::WriteLine(L"\noranges are not the only fruit...");
    Console::Write(L"- and we have ");
    Console::Write(fruit);
    Console::Write(L" fruits in all.\n");

    int packageCount = 25;
    /*Console::Write(L"There are  ");
    Console::Write(packageCount);
    Console::WriteLine(L" packages.");
*/
    Console::WriteLine(L"There are {0} packages.", packageCount);          //一句顶 3 句

    double packageWeight = 9.5;
    Console::WriteLine(L"there are {0} packages weight {1} pounds.",packageCount,packageWeight);
    Console::WriteLine(L"there are {0} packages weight {1:F2} pounds.",packageCount,packageWeight);
    Console::WriteLine(L"there are {0,3} packages weight {1,5:F2} pounds.",packageCount,packageWeight);


    system("pause");
    return 0;
}


这是世界上最笨的学习方法!没有老师教,只好这样学。

4 回复
#2
lintaoyn2010-08-19 16:35
int apples = 5,oranges = 6;
int fruit = apples  + oranges;
//这样写也能紧凑些

   
#3
pangding2010-08-19 23:33
int main(array<System::String ^> ^args)
这种声明是什么意思?也是 windows 下的扩展吗?样子够怪的……
#4
zhoufeng19882010-08-20 01:10
嗯啊,我还是以为是MC++呢~
#5
hmsabc2010-08-20 15:45
回复 3楼 pangding
这是VS2005自动生成的控制台应用程序,我也不知道哪些参数是什么意思,正在学。
1