1. 程式人生 > >C++入門經典-例2.15-逗號表達式的應用

C++入門經典-例2.15-逗號表達式的應用

++ space c++ oid 技術分享 printf play 代碼 using

1:代碼如下:

技術分享
// 2.15.cpp : 定義控制臺應用程序的入口點。
#include "stdafx.h"
#include<iostream>
using namespace std;
void main()
{
    int a=4,b=6,c=8,res1,res2;
    res1=a,res2=b+c;
    for(int i=0,j=0;i<2;i++)
    {
        printf("y=%d,x=%d\n",res1,res2);
    }
}
View Code

運行結果:

技術分享

C++入門經典-例2.15-逗號表達式的應用