当前位置:网站首页>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
边栏推荐
- [free sharing] kotalog diary2022 plan electronic manual ledger
- Merge K ascending linked lists
- Basic principle of LSM tree
- 第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
- [proteus simulation] a simple encrypted electronic password lock designed with 24C04 and 1602LCD
- We have built an intelligent retail settlement platform
- How to design a high concurrency system
- P1891 crazy LCM (Euler function)
- 第一章:递归求n的阶乘n!
- 为什么要做特征的归一化/标准化?
猜你喜欢
第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
Free year-end report summary template Welfare Collection
Flutter network and data storage framework construction-b1
What does a really excellent CTO look like in my eyes
This Chinese numpy quick look-up table is too easy!
[disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]
Merge K ascending linked lists
Foundation of ActiveMQ
第一章:求奇因数代数和,求同吗小数和s(d, n),简化同码小数和s(d, n),拓广同码小数和s(d, n)
【疾病识别】基于matlab GUI机器视觉肺癌检测系统【含Matlab源码 1922期】
随机推荐
Dart JSON编码器和解码器剖析
Pecan - route
Common text labels
【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking
The most valuable thing
Floating source code comment (38) parallel job processor
第一章: 舍罕王失算
【疾病识别】基于matlab GUI机器视觉肺癌检测系统【含Matlab源码 1922期】
[new year job hopping season] test the technical summary of interviewers' favorite questions (with video tutorials and interview questions)
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
EGO Planner代码解析bspline_optimizer部分(1)
[leetcode] [SQL] notes
Valentine's Day - make an exclusive digital collection for your lover
Redis master-slave synchronization, clustering, persistence
math_ Taylor formula
第一章:求所有阶乘和数,大奖赛现场统分程序设计,三位阶乘和数,图形点扫描,递归求n的阶乘n!,求n的阶乘n!,舍罕王失算
math_泰勒公式
Using the visualization results, click to appear the corresponding sentence
Basic principle of LSM tree