当前位置:网站首页>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
边栏推荐
- 05 -- QT OpenGL draw cube uniform
- Thesis study - 7 Very Deep Convolutional Networks for Large-Scale Image Recognition (3/3)
- QT -- qfile file read / write operation
- [free sharing] kotalog diary2022 plan electronic manual ledger
- 东数西算拉动千亿产业,敢啃“硬骨头”的存储厂商才更有机会
- Scrape crawler framework
- How does if ($variable) work? [repeat] - how exactly does if ($variable) work? [duplicate]
- EGO Planner代码解析bspline_optimizer部分(3)
- Webrtc[41] - Analysis of the establishment process of webrtc transmission channel
- Web Security (VII) specific process of authentication with session cookie scheme
猜你喜欢

Foundation of ActiveMQ

【Proteus仿真】用24C04与1602LCD设计的简易加密电子密码锁

Ego planner code parsing Bspline_ Optimizer section (3)

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

第二章:4位卡普雷卡数,搜索偶数位卡普雷卡数,搜索n位2段和平方数,m位不含0的巧妙平方数,指定数字组成没有重复数字的7位平方数,求指定区间内的勾股数组,求指定区间内的倒立勾股数组
![[disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]](/img/fc/00835b95537cf889588502a3d13bc9.png)
[disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]

Valentine's Day - make an exclusive digital collection for your lover

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

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

Flutter network and data storage framework construction-b1
随机推荐
04 -- QT OpenGL two sets of shaders draw two triangles
Analyse du Code du planificateur ego bspline Section Optimizer (1)
Floating source code comment (38) parallel job processor
The most valuable thing
Zhang Fei hardware 90 day learning notes - personal record of day 3, please see my personal profile / homepage for the complete
[leetcode] [SQL] notes
Find the median of two positive arrays
论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数
Day_ 18 IO stream system
05 -- QT OpenGL draw cube uniform
[new year job hopping season] test the technical summary of interviewers' favorite questions (with video tutorials and interview questions)
Pecan — Overview
【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
【疾病识别】基于matlab GUI机器视觉肺癌检测系统【含Matlab源码 1922期】
I didn't cancel
第一章:求所有阶乘和数,大奖赛现场统分程序设计,三位阶乘和数,图形点扫描,递归求n的阶乘n!,求n的阶乘n!,舍罕王失算
Day18 - basis of interface testing
第一章:拓广同码小数和s(d, n)
Detailed explanation of shuttle unity interworking principle