网络技术C语言
一,千、百、十、个类型(23个题)
16.
四位数,满足千加个等于百加十的个数cnt,以及求出满足此条件的平均值pjz1;和不满足此条件的pjz2
int i,q,bi,s,g;
pjz1=0;
pjz2=0;
for(i&#61;0;i<300;i&#43;&#43;)
{ q&#61;a[i]/1000;
bi&#61;a[i]%1000/100;
s&#61;a[i]%100/10;
g&#61;a[i]%10;
if(q&#43;g&#61;&#61;bi&#43;s)
{ cnt&#43;&#43;; pjz1&#61;pjz1&#43;a[i];}
else pjz2&#61;pjz2&#43;a[i];
}
if(cnt&#61;&#61;0) pjz1&#61;0;
else pjz1&#61;pjz1/cnt;
if(300-cnt&#61;&#61;0) pjz2&#61;0;
else pjz2&#61;pjz2/(300-cnt);
18.
四位数&#xff0c;满足千加百等于十加十的个数cnt,以及求出满足此条件的平均值pjz1;和不满足此条件的pjz2
int i,q,bi,s,g;
for(i&#61;0;i<300;i&#43;&#43;)
{ q&#61;a[i]/1000;
bi&#61;a[i]%1000/100;
s&#61;a[i]%100/10;
g&#61;a[i]%10;
if(q&#43;bi&#61;&#61;gi&#43;s)
{ cnt&#43;&#43;; pjz1&#61;pjz1&#43;a[i];}
else pjz2&#61;pjz2&#43;a[i];
}
if(cnt&#61;&#61;0) pjz1&#61;0;
else pjz1&#61;pjz1/cnt;
if(300-cnt&#61;&#61;0) pjz2&#61;0;
else pjz2&#61;pjz2/(300-cnt);
19
四位数&#xff0c;满足千减百减十减个大于零的个数cnt,以及求出满足此条件的平均值pjz1;和不满足此条件的pjz2
int i,q,bi,s,g;
pjz1&#61;0;
pjz2&#61;0;
for(i&#61;0;i<300;i&#43;&#43;)
{ q&#61;a[i]/1000;
bi&#61;a[i]%1000/100;
s&#61;a[i]%100/10;
g&#61;a[i]%10;
if(q-bi-s-g>0)
{ cnt&#43;&#43;; pjz1&#61;pjz1&#43;a[i];}
else pjz2&#61;pjz2&#43;a[i];
}
if(cnt&#61;&#61;0) pjz1&#61;0;
else pjz1&#61;pjz1/cnt;
if(300-cnt&#61;&#61;0) pjz2&#61;0;
else pjz2&#61;pjz2/(300-cnt);
22
四位数&#xff0c;满足个减千减百减十大于零的个数cnt&#xff0c;再把满足此条件的数依次存放到b数组中&#xff0c;然后对b数组中的数据从大到小排列&#xff1b;
int i,q,bi,s,g,t;
for(i&#61;0;i<300;i&#43;&#43;)
{ q&#61;a[i]/1000;
bi&#61;a[i]%1000/100;
s&#61;a[i]%100/10;
g&#61;a[i]%10;
if(g-q-bi-s>0)
{ b[cnt]&#61;a[i]; cnt&#43;&#43;;}
}
for(i&#61;0;i
for(j&#61;i&#43;1;j
if(b[i]
{ t&#61;b[i];b[i]&#61;b[j];b[j]&#61;t;}
30
5000以下的自然数&#xff0c;满足千加百等于十加个并且千加百等于个减千之差的10倍。求此个数&#xff0c;及和sum.
int i,q,bi,s,g;
for(i&#61;1;i<5000;i&#43;&#43;)
{ q&#61;i/1000;
bi&#61;i%1000/100;
s&#61;i%100/10;
g&#61;i%10;
if((q&#43;bi&#61;&#61;s&#43;g)&&(q&#43;b)&#61;&#61;(g-q)*10)
{ cnt&#43;&#43;; sum&#61;sum&#43;i;}
}
36四位数&#xff0c;满足千减百减十减个大于零的个数cnt&#xff0c;再把满足此条件的数依次存放到b数组中&#xff0c;然后对b数组中的数据从小到大排列&#xff1b;
int i,q,bi,s,g,t;
for(i&#61;0;i<300;i&#43;&#43;)
{ q&#61;a[i]/1000;
bi&#61;a[i]%1000/100;
s&#61;a[i]%100/10;
g&#61;a[i]%10;
if(q-bi-s-g>0)
{ b[cnt]&#61;a[i]; cnt&#43;&#43;;}
}
for(i&#61;0;i
for(j&#61;i&#43;1;j
if(b[i]>b[j])
{ t&#61;b[i];b[i]&#61;b[j];b[j]&#61;t;}
37
四位数&#xff0c;满足千加百等于十加个的个数cnt&#xff0c;再把满足此条件的数依次存放到b数组中&#xff0c;然后对b数组中的数据从大到小排列&#xff1b;
int i,q,bi,s,g,t;
for(i&#61;0;i<300;i&#43;&#43;)
{ q&#61;a[i]/1000;
bi&#61;a[i]%1000/100;
s&#61;a[i]%100/10;
g&#61;a[i]%10;
if(q&#43;bi&#61;&#61;s&#43;g)
{ b[cnt]&#61;a[i]; cnt&#43;&#43;;}
}
for(i&#61;0;i