C语言 a[56]={41,45,44,44,26,44,42,20,20,38,37,25,45,45,45,44,2
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/08/28 22:01:59
C语言
a[56]={41,45,44,44,26,44,42,20,20,38,37,25,45,45,45,44,20,30,39,35,38,38,28,25,30,36,20,24,32,33,41,33,51,39,20,20,44,37,38,39,42,40,37,50,50,42,43,41,42,45,42,19,39,75,17,17};任意几个数之和等于150,输出其顺序号和数字.不能组成的数字同样输出其顺序号和数字.
#include "stdafx.h"
#include
#include
void main()
{
int sum=0;
int i,
a[56]={41,45,44,44,26,44,42,20,20,38,37,25,45,45,45,44,20,30,39,35,38,38,28,25,30,36,20,24,32,33,41,33,51,39,20,20,44,37,38,39,42,40,37,50,50,42,43,41,42,45,42,19,39,75,17,17};
for(i=0;i100&&sum
a[56]={41,45,44,44,26,44,42,20,20,38,37,25,45,45,45,44,20,30,39,35,38,38,28,25,30,36,20,24,32,33,41,33,51,39,20,20,44,37,38,39,42,40,37,50,50,42,43,41,42,45,42,19,39,75,17,17};任意几个数之和等于150,输出其顺序号和数字.不能组成的数字同样输出其顺序号和数字.
#include "stdafx.h"
#include
#include
void main()
{
int sum=0;
int i,
a[56]={41,45,44,44,26,44,42,20,20,38,37,25,45,45,45,44,20,30,39,35,38,38,28,25,30,36,20,24,32,33,41,33,51,39,20,20,44,37,38,39,42,40,37,50,50,42,43,41,42,45,42,19,39,75,17,17};
for(i=0;i100&&sum
总共也就27720次测试
下面的代码,只输出了满足要求的数字(不满足的你想输出的话稍改一下)
和等于150的,不等于150的,全部输出来,那跑这段代码是为了什么啊.有27720组数据啊.
void main()
{
int a[56]={41,45,44,44,26,44,42,20,20,38,37,25,45,45,45,44,20,30,39,35,38,38,28,25,30,36,20,24,32,33,41,33,51,39,20,20,44,37,38,39,42,40,37,50,50,42,43,41,42,45,42,19,39,75,17,17};
int i, j, k;
#define N56
#define SUM150
int total = 0;
for(i = 0; i < N - 2; i ++)
for(j = i + 1; j < N -1; j++)
for(k = j + 1; k < N; k++)
{
if(a[i] + a[j] + a[k] == SUM)
{
printf("%d(%d),%d(%d),%d(%d)\r\n", a[i], i, a[j], j, a[k], k);
total++;
}
}
printf("%d\r\n", total);
}
下面的代码,只输出了满足要求的数字(不满足的你想输出的话稍改一下)
和等于150的,不等于150的,全部输出来,那跑这段代码是为了什么啊.有27720组数据啊.
void main()
{
int a[56]={41,45,44,44,26,44,42,20,20,38,37,25,45,45,45,44,20,30,39,35,38,38,28,25,30,36,20,24,32,33,41,33,51,39,20,20,44,37,38,39,42,40,37,50,50,42,43,41,42,45,42,19,39,75,17,17};
int i, j, k;
#define N56
#define SUM150
int total = 0;
for(i = 0; i < N - 2; i ++)
for(j = i + 1; j < N -1; j++)
for(k = j + 1; k < N; k++)
{
if(a[i] + a[j] + a[k] == SUM)
{
printf("%d(%d),%d(%d),%d(%d)\r\n", a[i], i, a[j], j, a[k], k);
total++;
}
}
printf("%d\r\n", total);
}
C语言 a[56]={41,45,44,44,26,44,42,20,20,38,37,25,45,45,45,44,2
C语言 写一个 指定数组中产生随机数 int a[9] = {2,5,9,35,44,37,63,6,17,28} 随机
一维数组中所有偶数元素的平方根之和,A数组的数据为53,78,93,45,41,34,12,90,26,75.c语言
C语言 sum += *(a +
c 语言 k=(a++
C语言if ((c>='a'&&c='A'&&c
C语言,a=10,b=20,c=35,求平均数,菜鸟求编程~
C语言中c=a
C语言c=(a^b)
C语言中,a=(b,c) ,
c语言中,符号a=2,b=a
C语言中,a=10b=20,表达式!a