当前位置:网站首页>Chapter 1: sum of three factorials, graph point scanning
Chapter 1: sum of three factorials, graph point scanning
2022-07-03 19:21:00 【Shares_ four】
long fac2 (int x)
{
int i;
long p=1;
for (i=1;i<=x;i++)
p*=i;
return (p);
}
int main()
{
int a, b, c, m,n;
printf(" The sum of three factorials has :");
for (a = 1; a <= 6; a++)
for (b = 0; b <= 6; b++)
for (c=0; c <= 6; c++)
{
m = a * 100 + b * 10 + c;
n = fac2(a) + fac2(b) + fac2(c);
if (m==n) printf ("%d \n", m) ;
}
}
result :
// Graph point scanning Find the map area
int main()
{
FILE *fp;
char fname[50]; // The length of the file name is not greater than 50
int i, j, x, y, k, s, w, t, a[12] [12] ;
printf (" \n input file name: ");
gets (fname);
if ( (fp=fopen (fname, "r")) == NULL)
{
printf( "The file was not opened n" ) ;
return 0;
}
x = 11;
y = 11;
for (i=0; i <=y; ++i)
{
printf("\n ");
for(j=0; j<=x;++j)
{
fscanf(fp, "%d", &a[i][j]); //, Read data from file to 2D a Array
printf("%d ",a[i][j]);
}
}
for(i = 0; i <= x ;++i)
{
if(a[0][i] == 0)
a[0][i] = 2;
if(a[y][i] == 0)
a[y][i] = 2;
}
for(i = 1; i <= y ;++i)
{
if(a[i][0] == 0)
a[i][0] = 2;
if(a[i][x] == 0)
a[i][x] = 2;
}
t = x * y;
for (k=1;k<t; ++k)
{
w = 0;
for (i = 1; i < y; ++i)
for( j = 1; j < x; ++j)
if((a[i][j-1] == 2 || a[i][j+1] == 2 || a[i-1][j] == 2 || a[i+ 1][j] == 2) && a[i][j] == 0)
{
a[i][j] = 2;
w = 1;
}
}
s = 0;
printf("\n ");
for(i = 0; i <= y; ++i)
{
printf("\n ");
for(j = 0; j <= x; ++j)
{
if(a[i][j] == 0) s += 1;
printf("%d", a[i][j]);
}
}
printf("\n s = %d\n", s);
fclose(fp);
return 0;
}
result :
File path :
The contents of the document :
PS: There will be garbled code without spaces
边栏推荐
- 记录在模拟器中运行flutter时报的错
- Floating source code comment (38) parallel job processor
- Recommend a GIF processing artifact less than 300K - gifsicle (free download)
- [wallpaper] (commercially available) 70 wallpaper HD free
- High concurrency Architecture - read write separation
- Read the paper glodyne global topology preserving dynamic network embedding
- Ego planner code parsing Bspline_ Optimizer section (3)
- During MySQL installation, the download interface is empty, and the components to be downloaded are not displayed. MySQL installer 8.0.28.0 download interface is empty solution
- P1891 crazy LCM (Euler function)
- [optics] dielectric constant calculation based on MATLAB [including Matlab source code 1926]
猜你喜欢
![[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time](/img/06/5a37e2dca9711f8322b657581c3d75.png)
[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time

Free sharing | linefriends hand account inner page | horizontal grid | not for sale

Record: solve the problem that MySQL is not an internal or external command environment variable

Flume learning notes

Merge K ascending linked lists
![[water quality prediction] water quality prediction based on MATLAB Fuzzy Neural Network [including Matlab source code 1923]](/img/aa/9980acc9839f067202d46faabbf029.png)
[water quality prediction] water quality prediction based on MATLAB Fuzzy Neural Network [including Matlab source code 1923]

Simulation scheduling problem of SystemVerilog (1)

Leetcode 1189. Maximum number of balloons (special character count)

Record: install MySQL on ubuntu18.04

Flutter网络和数据存储框架搭建 -b1
随机推荐
Web Security (VIII) what is CSRF attack? Why can token prevent csdf attacks?
The earliest record
01 - QT OpenGL display OpenGL window
Analyse du Code du planificateur ego bspline Section Optimizer (1)
【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
During MySQL installation, the download interface is empty, and the components to be downloaded are not displayed. MySQL installer 8.0.28.0 download interface is empty solution
Simulation scheduling problem of SystemVerilog (1)
Foundation of ActiveMQ
Yolov3 network model building
Simple solution of physical backup and restore of Damon database
【光学】基于matlab涡旋光产生【含Matlab源码 1927期】
Driveseg: dynamic driving scene segmentation data set
Basic principle of LSM tree
Compared with 4G, what are the advantages of 5g to meet the technical requirements of industry 4.0
Smart wax therapy machine based on STM32 and smart cloud
PyTorch中在反向传播前为什么要手动将梯度清零?
Sentinel source code analysis part II - sentinel dashboard console startup and configuration
Counting from the East and counting from the West will stimulate 100 billion industries. Only storage manufacturers who dare to bite the "hard bone" will have more opportunities
第二章:4位卡普雷卡数,搜索偶数位卡普雷卡数,搜索n位2段和平方数,m位不含0的巧妙平方数,指定数字组成没有重复数字的7位平方数,求指定区间内的勾股数组,求指定区间内的倒立勾股数组
flask 生成swagger文档