2.1 CDAA
2.2
1.5 3 4
2.x>20&&x<30||x<-100
3.52
4.1 for(i=1;i<=10;i++)
5.x>=0 x<amin
2.3
1.
#include <stdio.h>
#include <math.h>
void main()
{
int n=1,x,y;
while(1)
{
x=sqrt(100+n);
y=sqrt(168+n);
if(x*x==(100+n) && y*y==(168+n))
break;
n++;
}
printf("%d",n);
}
2.
void main()
{
int n,n1,n2,n3,n4,n5;
printf("please input n:");
scanf("%d",&n);
printf("n=%d\n",n);
n1=n/10000;
n2=n%10000/1000;
n3=n%1000/100;
n4=n%100/10;
n5=n%10;
if(n1!=0) printf("n is 5 wei shu!\n");
else if(n2!=0) printf("n is 4 wei shu!\n");
else if(n3!=0) printf("n is 3 wei shu!\n");
else if(n4!=0) printf("n is 2 wei shu!\n");
else if(n5!=0) printf("n is 1 wei shu!\n");
if(n5!=0)printf("%d",n5);
if(n4!=0)printf("%d",n4);
if(n3!=0)printf("%d",n3);
if(n2!=0)printf("%d",n2);
if(n1!=0)printf("%d",n1);
}
3.
void main()
{
int i,n,a,t,sum=0;
printf("please input n and a:");
scanf("%d%d",&n,&a);
t=a;
for(i=1;i<=n;i++)
{
sum=sum+a;
a=a*10+t;
}
printf("Sn=%d",sum);
}
4.略(学完“数组”后再做此题)
5.
void main()
{
float sn=100.0,hn=sn/2;
int n;
for(n=2;n<=10;n++)
{
sn=sn+2*hn;
hn=hn/2;
}
printf("the total of road is %f\n",sn);
printf("the tenth is %f meter\n",hn);
}
6.略
7.
void main()
{
int n,t,number=20;
float a=2,b=1,s=0;
for(n=1;n<=number;n++)
 {
  s=s+a/b;
  t=a;a=a+b;b=t;/*这部分是程序的关键,请猜猜t的作用*/
 }
printf("sum is %9.6f\n",s);
}
8.
#include<stdio.h>
void main()
{
char ch;
int cap=0,alp=0,spa=0,num=0,other=0;
printf("please input some letters:");
while((ch=getchar())!='\n')
{
if(ch>='0'&&ch<='9') num++;
else if(ch>='A'&&ch<='Z') cap++;
else if(ch>='a'&&ch<='z') alp++;
else if(ch==' ') spa++;
else other++;
}
printf("Capital letter=%d,Lowercase letter=%d,Number=%d,Space=%d,
Others=%d\n",cap,alp,num,spa,other);
}