当前位置:网站首页>Chapter 1: find all factorial sums, Grand Prix site unified programming, three factorial sums, graphic point scanning, recursive factorial n of n!, Find the factorial n of n!, King Shehan miscalculate
Chapter 1: find all factorial sums, Grand Prix site unified programming, three factorial sums, graphic point scanning, recursive factorial n of n!, Find the factorial n of n!, King Shehan miscalculate
2022-07-03 19:21:00 【Shares_ four】
// Find the sum of all factorials
long fac3 (int x)
{
int i;
long p=1;
for (i=1 ;i<=x;i++)
p*=i;
return (p);
}
int main()
{
int a, b, c, d, e, f, g;
long m1, m2, m3, m4, m5, m6, n1, n2, n3, n4, n5, n6;
printf(" All factorial sums have : ");
for (a = 1; a <9;a++)
{
if (a == fac3(a))
printf("%d", a);
for (b=0;b <= 9;b++)
{
m1 = a * 10 + b;
n1=fac3 (a) + fac3 (b);
if(m1 == n1)
printf("%ld ", m1);
for (c=0;c<=9; c++)
{
m2 = m1 * 10 + c;
n2 = n1 + fac3(c);
if(m2 == n2)
printf("%ld", m2);
for (d=0; d <= 9; d++)
{
m3 = m2 * 10 + d;
n3 = n2 +fa3c(d);
if (m3==n3) printf("%ld" , m3);
for(e=0; e <= 9; e++)
{
m4 = m3 * 10 + e;
n4 = n3 + fac3 (e);
if(m4==n4)
printf("%ld", m4) ;
for(f = 0; f <= 9; f++)
{
m5 = m4 * 10 + f;
n5 = n4 + fac3(f);
if( m5 == n5)
printf("%ld",m5);
for( g = 0; g <= 9; g++)
{
m6 = m5 * 10 + g;
n6 = n5 + fac3(g);
if( m6 == n6)
printf("%ld",m6);
}
}
}
}
}
}
}
return 0;
}
result :
// Grand Prix site integration program design
int main()
{
int i, j, n, m, u, sh[40], ph[20];
double a,b, c, max, min, uf, sf[40], pf[20],z[40], f[40][20];
printf(" Please enter the number of players (1<n<40): ");
scanf ("%d", &n);
printf(" Please enter the number of judges (2<m<20):");
scanf ("%d", &m);
for (j=1; j <= m; j++)
ph[j] = j;
for(i = 1; i <= n; i++) // Score the contestants on site , Unified Division
{
printf ("\n The first %d Contestants are numbered : ",i);
scanf("%d",&sh[i]);// Enter the first i Player numbers
sf[i]=0;
max=0;
min=100;
for(j=1; j <= m; j++)
{
printf(" The first %d Judges rated :",j);
scanf("%lf",&f[i][j]);
sf[i] += f[i][j];
if (max < f[i][j])
max = f[i][j]; // Enter the first j The first judge is i Scores of players // Count the highest and lowest scores
if (min > f[i][j])
min = f[i][j];
}
printf("\n Remove one of the highest scores :%.3f",max);
printf("\n Remove a minimum score :%.3f",min);
sf[i]= (sf[i]-max-min) / (m-2); // The first i The final score of players
a = max-sf[i];
b = sf[i]-min;
z[i] = (a>b) ?a:b;
printf ("\n The number is %d Contestant No ",sh[i]);
printf(" The final score is :%.3f",sf[i]); // Yibudi i Scores of players
}
for (c=0, i=1; i <= n;i++)
c += z[i] * z[i];
c = sqrt (c/n); // Score the judges
for(j=1; j <= m; j++)
{
pf[j]=0;
for (i=1; i <=n; i++)
pf[j]+=(f[i][j]-sf[i]) * (f[i][j]-sf[i]);
pf[j] = 10.0 - sqrt(pf[j]/n) /c*5;
printf("\n The first %d Judge No. scored :%.3f",j,pf[j]);
}
for(i = 1; i <= n; i++)
for(j = i +1; j <= n; j++)
if(sf[i] < sf[j])
{
uf = sf[i];
sf[i] = sf[j];
sf[j] = uf;
u = sh[i];
sh[i] = sh[j];
sh[j] = u;
}
printf ("\n Score ranking table of contestants ");
printf("\n Player number score Ranking ");
for (i=1; i <= n; i++)
printf ("\n %d %.3f %d", sh[i], sf[i], i) ;
printf("\n");
for(j = 1;j <= m-1;j++) // The judges' scores are ranked from high to low Count
for (i = j+1;i <= m;i++)
if (pf[j] < pf[i])
{
uf = pf[j];
pf[j] = pf[i];
pf[i] = uf;
u = ph[j];
ph[j] = ph[i];
ph[i] = u;
}
printf("\n Ranking table of judges ");
printf ("\n Judge No score Ranking ");
for(j=1;j <= m; j++)
printf ("\n %d %.3f %d", ph[j], pf [j], j) ;
printf ("\n The competition ends , thank you !\n");
return 0;
}
result :

// Sum of three factorials
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
// Recursive search n The factorial n!
long fac1(int n)
{
long f;
if (n == 1) f = 1;
else f = n * fac1(n - 1);
return (f);
}
int main()
{
int n;
long y;
printf(" Please enter n(n < 13):");
scanf("%d", &n);
if (n > 12)
{
printf(" Input n Over the limit 12, Please re-enter n.\n");
return 0;
}
y = fac1(n);
printf(" %d! = %ld\n", n, y);
return 0;
}
result :
// seek n The factorial n!
int main()
{
int k, n;
long t;
printf(" Please enter n (n < 3)", &n);
scanf("%d", &n);
t = 1;
for (k = 1; k <= n; k++)
t = t * k;
printf(" %d != %ld\n", n, t);
return 0;
}
result :
// King Shehan miscalculated
int main()
{
double t, s, v, p;
int i, n;
printf(" Please enter the number of cells n:");
scanf("%d", &n);
t = 1;
s = 1;
for (i = 2; i <= n; i++)
{
t = t * 2;
s += t;
}
v = s / 2.4e7;
p = v / 2.48e9;
if (n <= 40) printf(" The total number of grains is :%.0f\n", s);
else printf(" The total number of grains is :%.3e\n", s);
printf(" The weight of wheat is about :%f Tons of \n", v);
printf(" It is about... Of the world's total annual grain output %.0f times \n", p);
return 0;
}
result :
边栏推荐
- This Chinese numpy quick look-up table is too easy!
- Day10 ---- 强制登录, token刷新与jwt禁用
- [leetcode] [SQL] notes
- Web Security (VIII) what is CSRF attack? Why can token prevent csdf attacks?
- [water quality prediction] water quality prediction based on MATLAB Fuzzy Neural Network [including Matlab source code 1923]
- Dynamic planning -- expansion topics
- Dart JSON编码器和解码器剖析
- Day_ 18 IO stream system
- SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)
- The most valuable thing
猜你喜欢

During MySQL installation, the download interface is empty, and the components to be downloaded are not displayed. MySQL installer 8.0.28.0 download interface is empty solution
![[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]

Octopus online ecological chain tour Atocha protocol received near grant worth $50000

Flutter网络和数据存储框架搭建 -b1
![[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]

记录在模拟器中运行flutter时报的错

第二十章:y= sin(x)/x,漫步坐标系计算,y= sin(x)/x 带廓幅图形,奥运五环,小球滚动与弹跳,流水显示,矩形优化裁剪,r个皇后全控nxn棋盘

Chapitre 1: le roi de shehan a mal calculé

Leetcode 1189. Maximum number of balloons (special character count)
![[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time](/img/06/5a37e2dca9711f8322b657581c3d75.png)
[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time
随机推荐
I study database at station B (4): DQL
论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
SQL injection for Web Security (1)
QT -- qfileinfo file information reading
第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
Day18 - basis of interface testing
FBI warning: some people use AI to disguise themselves as others for remote interview
第二章:4位卡普雷卡数,搜索偶数位卡普雷卡数,搜索n位2段和平方数,m位不含0的巧妙平方数,指定数字组成没有重复数字的7位平方数,求指定区间内的勾股数组,求指定区间内的倒立勾股数组
The earliest record
Chapter 1: simplify the same code decimal sum s (D, n)
Cross compile opencv with contrib
EGO Planner代码解析bspline_optimizer部分(2)
TFs and SVN [closed] - TFs vs SVN [closed]
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
Thesis study - 7 Very Deep Convolutional Networks for Large-Scale Image Recognition (3/3)
Record: MySQL changes the time zone
Flutter网络和数据存储框架搭建 -b1
Thinking about festivals
Analysis of dart JSON encoder and decoder
Php based campus lost and found platform (automatic matching push)