zoukankan      html  css  js  c++  java
  • 判断闰年

    1.判断闰年

    2.输出9x9乘法表

    3.输出100-200之内的素数

    我们接下来用三个函数实现三者,然后main函数调用

    #include "stdio.h"

    #include "stdlib.h"

    #include "math.h"

    int leap(int year){

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

        return i;

      return 0;

    }

    void mulTable(){

      for(int i = 1;i < 10;i++){

        for(int j = 1;j<=i;j++){

          printf("%d * %d = %d ",i,j,(i*j));

        }

        printf(" ");

      }

    }

    int prime(int i ){

      int j = 2;

      while(j < sqrt(i)){

        if(i%j == 0)

          break;

        j++; 

      }

      if(j == sqrt(i))

        return i;

      return 0;

    }

    int main(){

      //输出乘法表

      mulTable();

      //判断闰年

      for(int i = 1000;i<=2000;i++){

        if( leap(i))

          printf("%d ",leap(i));

      }

      //输出素数

      for(int i = 1000;i<=2000;i++){

        if( prime(i))

          printf("%d ",prime(i));

      }

      system("pause");

      return 0;

    }

  • 相关阅读:
    How to access the properties of an object in Javascript
    他们不是机器人
    sql 使用整理
    地图上计算两点间的距离.(参考网络)
    window.location.reload被弃用?
    BitBlt
    BitBlt介绍
    C#大数计算 .Net Framework4.0以下
    C# ToString格式化
    Ubuntu修改时区和更新时间
  • 原文地址:https://www.cnblogs.com/du001011/p/10010367.html
Copyright © 2011-2022 走看看