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;

    }

  • 相关阅读:
    Codeforces Round #674 (Div. 3)C. Increase and Copy
    Calendar Game
    poj3255Roadblocks
    L2-008 最长对称子串
    L2-004 这是二叉搜索树吗?
    D. Boboniu Chats with Du Codeforces Round #664 (Div. 2)
    暑假了,冲冲冲
    逆元和同余
    懒惰的我
    Codeforces Round #594 (Div. 2) C题
  • 原文地址:https://www.cnblogs.com/du001011/p/10010367.html
Copyright © 2011-2022 走看看