程序【1】
topic:1,2,3,4 Number,how many are the same and no repeat number that can be made of three dights?how much is?
题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
#include
int main ()
{
// int i,j,k,sum;
int i,j,k;
for (i=1;i<5;i++)
for (j=1;j<5;j++)
for (k=1;k<5;k++){
if (i!=j&&i!=k&&j!=k) //sure the number different anyone
// printf ("%d\n",sum);//计算机上的只是二进制机器码没有数学上的百十含义
// 如123printf只是原样输出,没有一百二十三的数学意义
printf("%d%d%d\n",i,j,k);
}
return 0;
}
程序【2】
topic :An integer, it added after the 100 is a perfect square number, plus 168 is a perfect square number(完全平方数)
题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?
#include
#include
int main ()
{
int i,j,a;
i = sqrt(a+100);
j = sqrt(a+268);
if (i*i == (a+100) && j*j == (a+268))) //开方取整后j,k如果不是完全平方数则变小
printf("%d\n",a);
return 0;
}
程序【3】
topic :input one number , judge this day is the number of days a year
题目:输入某年某月某日,判断这一天是这一年的第几天?
#include
int main ()
{
int year,month,day,sum;
scanf ("%d%d%d\n",&year,&month,&day);
switch(month)
{
case 1:
sum = 0;
break;
case 2:
sum = 31;
break;
case 3:
sum = 59;
break;
case 4:
sum = 90;
break;
default:
printf ("error\n");
break;
}
sum = sum +day;
if ((year %4 == 0 && year/100 ==0)
||year % 400 ==0 ) //判断是不是闰年
{
for (month >2)
++sum;
printf ("%d\n",sum);
}
else
printf("%d\n",sum);
return 0;
}