当前位置:网站首页>第一章:三位阶乘和数,图形点扫描
第一章:三位阶乘和数,图形点扫描
2022-07-03 19:16:00 【股_四】
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(" 三位阶乘和数有:");
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) ;
}
}
结果:
//图形点扫描 求地图面积
int main()
{
FILE *fp;
char fname[50]; //文件名长度在此约定不大于 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]); //,从文件读数据到二维a数组
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;
}
结果:
文件路径:
文件内容:
PS:没有空格会乱码
边栏推荐
- SSM integration - joint debugging of front and rear protocols (list function, add function, add function status processing, modify function, delete function)
- 235. The nearest common ancestor of the binary search tree [LCA template + same search path]
- High concurrency architecture cache
- Help change the socket position of PCB part
- Latex image rotates with title
- Buuctf's different flags and simplerev
- High concurrency Architecture - separate databases and tables
- 2020 intermediate financial management (escort class)
- What does a really excellent CTO look like in my eyes
- 【光学】基于matlab介电常数计算【含Matlab源码 1926期】
猜你喜欢
Integrated easy to pay secondary domain name distribution system
The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking
Add control at the top of compose lazycolumn
Ego planner code parsing Bspline_ Optimizer section (3)
Recommend a GIF processing artifact less than 300K - gifsicle (free download)
Sentinel source code analysis part I sentinel overview
Record: pymysql is used in pycharm to connect to the database
QT -- qfile file read / write operation
Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]. StandardContext
Pytorch introduction to deep learning practice notes 13- advanced chapter of cyclic neural network - Classification
随机推荐
【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
Thinking about festivals
Le changement est un thème éternel
[disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]
Nous avons fait une plateforme intelligente de règlement de détail
Record: pymysql is used in pycharm to connect to the database
High concurrency architecture cache
Octopus online ecological chain tour Atocha protocol received near grant worth $50000
Foundation of ActiveMQ
Flume learning notes
Recommend a GIF processing artifact less than 300K - gifsicle (free download)
【水质预测】基于matlab模糊神经网络水质预测【含Matlab源码 1923期】
Pytorch introduction to deep learning practice notes 13- advanced chapter of cyclic neural network - Classification
[proteus simulation] a simple encrypted electronic password lock designed with 24C04 and 1602LCD
Record: writing MySQL commands
The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking
Web Security (VIII) what is CSRF attack? Why can token prevent csdf attacks?
KINGS
Smart wax therapy machine based on STM32 and smart cloud
Random numbers in a long range, is that right- Random number in long range, is this the way?