C程编程问题.计算用0-9这些数字可以组成多少个没有重复数字的三位偶数,按每行6个输出,最后将输出的数求和.
2个回答
展开全部
#include "stdio.h"
#include "stdlib.h"
void main()
{
int hundred,ten,one;
int sum=0;
int count=0;
for (int i=100;i<999;i++)
{
hundred=i/100;
ten=(i-hundred*100)/10;
one=i%10;
if ((hundred==ten)||(hundred==one)||(ten==one)||(one%2==1))
continue;
else
{
count+=1;
printf("%d %d %d ",hundred,ten,one);
if ((count%6)==0)
{
printf("\n");
}
sum=sum+i;
}
}
printf("SUM of this number is %d\n",sum);
}
#include "stdlib.h"
void main()
{
int hundred,ten,one;
int sum=0;
int count=0;
for (int i=100;i<999;i++)
{
hundred=i/100;
ten=(i-hundred*100)/10;
one=i%10;
if ((hundred==ten)||(hundred==one)||(ten==one)||(one%2==1))
continue;
else
{
count+=1;
printf("%d %d %d ",hundred,ten,one);
if ((count%6)==0)
{
printf("\n");
}
sum=sum+i;
}
}
printf("SUM of this number is %d\n",sum);
}
展开全部
#include<stdio.h>
#include<stdlib.h>
void main()
{
int hundred,ten,one;
int sum=0;
int count=0;
for (int i=100;i<999;i++)
{
hundred=i/100;
ten=(i-hundred*100)/10;
one=i%10;
if ((hundred==ten)||(hundred==one)||(ten==one)||(one%2==1))
continue;
else
{
count+=1;
printf("%d %d %d ",hundred,ten,one);
if ((count%6)==0)
{
printf("\n");
}
sum=sum+i;
}
}
printf("SUM of this number is %d\n",sum);
system("pause");
}
#include<stdlib.h>
void main()
{
int hundred,ten,one;
int sum=0;
int count=0;
for (int i=100;i<999;i++)
{
hundred=i/100;
ten=(i-hundred*100)/10;
one=i%10;
if ((hundred==ten)||(hundred==one)||(ten==one)||(one%2==1))
continue;
else
{
count+=1;
printf("%d %d %d ",hundred,ten,one);
if ((count%6)==0)
{
printf("\n");
}
sum=sum+i;
}
}
printf("SUM of this number is %d\n",sum);
system("pause");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询