求高手把C语言的printf改成C++的cout形式
有红、黄、绿三种颜色的球,其中红球3个,黄球3个,绿球6个。现将这12个球放在一个盒子中,从中任意摸出8个球,编程计算摸出球的各种颜色搭配。#include<stdio....
有红、黄、绿三种颜色的球,其中红球3个,黄球3个,
绿球6个。现将这12个球放在一个盒子中,从中任意摸出8个球,
编程计算摸出球的各种颜色搭配。
#include<stdio.h>
#include<math.h>
main()
{
int red,yellow,green;
for(red=0;red<=3;red++)
for(yellow=0;yellow<=3;yellow++)
for(green=2;green<=8;green++)
if(red+yellow+green==8)
printf("%d %d %d\n",red,yellow,green);
} 展开
绿球6个。现将这12个球放在一个盒子中,从中任意摸出8个球,
编程计算摸出球的各种颜色搭配。
#include<stdio.h>
#include<math.h>
main()
{
int red,yellow,green;
for(red=0;red<=3;red++)
for(yellow=0;yellow<=3;yellow++)
for(green=2;green<=8;green++)
if(red+yellow+green==8)
printf("%d %d %d\n",red,yellow,green);
} 展开
展开全部
#include<stdio.h>改成#include<iostream.h>
printf("%d %d %d\n",red,yellow,green);改成cout << red << " " << yellow << " " << green << endl;
printf("%d %d %d\n",red,yellow,green);改成cout << red << " " << yellow << " " << green << endl;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
main()
{
int red,yellow,green;
for(red=0;red<=3;red++)
for(yellow=0;yellow<=3;yellow++)
for(green=2;green<=8;green++)
if(red+yellow+green==8)
cout << red << " " << yellow << " " << green << endl;
}
#include<iostream>
#include<math.h>
using namespace std;
main()
{
int red,yellow,green;
for(red=0;red<=3;red++)
for(yellow=0;yellow<=3;yellow++)
for(green=2;green<=8;green++)
if(red+yellow+green==8)
cout << red << " " << yellow << " " << green << endl;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询