当前位置:网站首页>第一章:三位阶乘和数,图形点扫描
第一章:三位阶乘和数,图形点扫描
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:没有空格会乱码
边栏推荐
- EGO Planner代碼解析bspline_optimizer部分(1)
- [proteus simulation] a simple encrypted electronic password lock designed with 24C04 and 1602LCD
- [leetcode] [SQL] notes
- 东数西算拉动千亿产业,敢啃“硬骨头”的存储厂商才更有机会
- Dynamic planning -- expansion topics
- ActiveMQ的基础
- QT -- qfileinfo file information reading
- Valentine's Day - make an exclusive digital collection for your lover
- [new year job hopping season] test the technical summary of interviewers' favorite questions (with video tutorials and interview questions)
- The way to treat feelings
猜你喜欢
![[optics] vortex generation based on MATLAB [including Matlab source code 1927]](/img/9b/b7f462e2ecbff0cee35e7de5c80cf7.jpg)
[optics] vortex generation based on MATLAB [including Matlab source code 1927]

【数学建模】基于matlab船舶三自由度MMG模型【含Matlab源码 1925期】

为什么要做特征的归一化/标准化?

Record: writing MySQL commands
![[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]

Sentinel source code analysis part I sentinel overview

Record the errors reported when running fluent in the simulator

A green plug-in that allows you to stay focused, live and work hard

FBI警告:有人利用AI换脸冒充他人身份进行远程面试

Php based campus lost and found platform (automatic matching push)
随机推荐
How to build an efficient information warehouse
【LeetCode】【SQL】刷题笔记
EGO Planner代码解析bspline_optimizer部分(1)
SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)
[water quality prediction] water quality prediction based on MATLAB Fuzzy Neural Network [including Matlab source code 1923]
【光学】基于matlab介电常数计算【含Matlab源码 1926期】
This Chinese numpy quick look-up table is too easy!
【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
Integrated easy to pay secondary domain name distribution system
What is the content of game modeling
Scrape crawler framework
Simulation scheduling problem of SystemVerilog (1)
Hard disk monitoring and analysis tool: smartctl
[leetcode] [SQL] notes
Find the median of two positive arrays
SSM integration - joint debugging of front and rear protocols (list function, add function, add function status processing, modify function, delete function)
[optics] vortex generation based on MATLAB [including Matlab source code 1927]
Help change the socket position of PCB part
Flume learning notes
Redis master-slave synchronization, clustering, persistence