当前位置:网站首页>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
边栏推荐
- Scrape crawler framework
- 我们做了一个智能零售结算平台
- Foundation of ActiveMQ
- Common text labels
- Analyse du Code du planificateur ego bspline Section Optimizer (1)
- Ego planner code parsing Bspline_ Optimizer section (3)
- 03 -- QT OpenGL EBO draw triangle
- 第二章:4位卡普雷卡数,搜索偶数位卡普雷卡数,搜索n位2段和平方数,m位不含0的巧妙平方数,指定数字组成没有重复数字的7位平方数,求指定区间内的勾股数组,求指定区间内的倒立勾股数组
- 第一章:求同吗小数和s(d, n)
- Find the median of two positive arrays
猜你喜欢

Integrated easy to pay secondary domain name distribution system

SSM integration - joint debugging of front and rear protocols (list function, add function, add function status processing, modify function, delete function)

Why should we do feature normalization / standardization?

If the warehouse management communication is not in place, what problems will occur?

Think of new ways

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

Foundation of ActiveMQ

Record: MySQL changes the time zone

第一章:求同吗小数和s(d, n)

【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
随机推荐
High concurrency Architecture - distributed search engine (ES)
[free sharing] kotalog diary2022 plan electronic manual ledger
[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time
记录在模拟器中运行flutter时报的错
Dart JSON编码器和解码器剖析
Read the paper glodyne global topology preserving dynamic network embedding
Random numbers in a long range, is that right- Random number in long range, is this the way?
Record: writing MySQL commands
Sentinel source code analysis part II - sentinel dashboard console startup and configuration
EGO Planner代码解析bspline_optimizer部分(1)
Ego planner code parsing Bspline_ Optimizer section (3)
第一章:求n的阶乘n!
Web Security (VIII) what is CSRF attack? Why can token prevent csdf attacks?
Zhang Fei hardware 90 day learning notes - personal record on day 5. Please see my personal profile / homepage for the complete record
第一章: 舍罕王失算
I study database at station B (4): DQL
Redis master-slave synchronization, clustering, persistence
EGO Planner代碼解析bspline_optimizer部分(1)
【水质预测】基于matlab模糊神经网络水质预测【含Matlab源码 1923期】
I didn't cancel