重学c语言(纯代码)

时间:2023-02-17 07:20:23

/*

int main()

{ //三个数中按从大到小排列

int a = 0;

int b = 0;

int c = 0;

int t = 0;

scanf("%d%d%d",&a,&b,&c);

if (a < b)

{

 t = a;

 a = b;

 b = t;

}

if (a < c)

{

 t = a;

 a = c;

 c = t;

}

if (b < c)

{

 t = b;

 b = c;

 c = t;

}

printf("%d%d%d",a,b,c);

return 0;

}

*/


/*

int main()

{ //计算出1-100中3的倍数

int i = 0;

for (i = 1; i<=100; i++)

{

 if (i % 3 == 0)

 printf("%d  ", i);

}

return 0;

}

*/


/*

int main()

{ //计算两数的公因数

int m = 0;

int n = 0;

int r = 0;

scanf("%d%d", &m, &n);

while (m%n)//≠0即运行while,=0即跳出while

{

 r = m % n;//改进:while(r=m%n)

 m = n;

 n = r;

}

printf("%d\n",n);

return 0;

}

*/


/*

int main()

{ //判断1000-2000年是否为闰年

int year = 0;

int count = 0;

for (year = 1000; year <= 2000; year++)

{//能被4整除并且不能被100整除  或  能被400整除是闰年

 if (year % 4 == 0 && year % 100 != 0)

 {

  printf("%d ",year);

  count++;

 }

 else if (year % 400 == 0)

 {

  printf("%d ",year);

  count++;

 }


}

printf("count= %d ", count);//计算有多少个闰年

return 0;

}

*/


/*

int main()

{

int year = 0;

int count = 0;

for (year = 1000; year <= 2000; year++)

{

 if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)

 {

  printf("%d ",year);

  count++;

 }

}

printf("count= %d\n ",count);

return 0;

}

*/


/*

int main()

{ //判断100-200中有多少素数,并列举

int i = 0;

int count = 0;

for (i = 100; i <= 200; i++)

{//判断i是否为素数-->

 int j = 0;

 for (j= 2; j < i; j++)

 {

  if (i%j == 0)

  {

   break;

  }

 }

 if (j == i)

 {

  count++;

  printf("%d ",j);

 }

}

printf("%d ",count);

return 0;

}

*/