当前位置:网站首页>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
边栏推荐
- Flask generates swagger documents
- How does if ($variable) work? [repeat] - how exactly does if ($variable) work? [duplicate]
- Integrated easy to pay secondary domain name distribution system
- 记录在模拟器中运行flutter时报的错
- 我眼中真正优秀的CTO长啥样
- Web Security (VIII) what is CSRF attack? Why can token prevent csdf attacks?
- Detailed explanation of shuttle unity interworking principle
- 论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
- Record: install MySQL on ubuntu18.04
- Latex image rotates with title
猜你喜欢

Php based campus lost and found platform (automatic matching push)

We have built an intelligent retail settlement platform

Merge K ascending linked lists

Free year-end report summary template Welfare Collection

PyTorch中在反向传播前为什么要手动将梯度清零?

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

Buuctf's different flags and simplerev

第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数

Flume learning notes

第二十章:y= sin(x)/x,漫步坐标系计算,y= sin(x)/x 带廓幅图形,奥运五环,小球滚动与弹跳,流水显示,矩形优化裁剪,r个皇后全控nxn棋盘
随机推荐
[mathematical modeling] ship three degree of freedom MMG model based on MATLAB [including Matlab source code 1925]
I study database at station B (4): DQL
Today I am filled with emotion
利用可视化结果,点击出现对应的句子
QT -- qfile file read / write operation
Scrape crawler framework
【疾病识别】基于matlab GUI机器视觉肺癌检测系统【含Matlab源码 1922期】
第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
Valentine's Day - make an exclusive digital collection for your lover
We have built an intelligent retail settlement platform
Comments on flowable source code (37) asynchronous job processor
Summary of 90 day learning materials and notes of Zhang Fei's actual electronic hardware engineer
Sentinel source code analysis part I sentinel overview
EGO Planner代碼解析bspline_optimizer部分(1)
第一章:求奇因数代数和,求同吗小数和s(d, n),简化同码小数和s(d, n),拓广同码小数和s(d, n)
Scrapy爬虫框架
Think of new ways
Zhang Fei hardware 90 day learning notes - personal record of day 3, please see my personal profile / homepage for the complete
Redis master-slave synchronization, clustering, persistence
Basic principle of LSM tree