Tagged with: C + +
1. Print the prime number between 100~200 #include<stdio.h> #include <math.h>int main () {int i=100,j=2;printf ("100-200 prime number: \ n") ; for (i=101;i<=200;i+=2) {int is_su=1;for (j=2;j<= (int) sqrt (i); j + +) if (i%j==0) {is_su=0;break;} if (IS_SU) printf ("%d\n", I);} return 0;} 2. Output multiplication table #include<stdio.h>int main () {int i,j;for (i=1;i<10;i++) {for (j=1;j<=i;j++) {printf ("%d*%d=%d", J , i,i*j);} printf ("\ n");} return 0;} 3. Judge the leap year between 1000---2000 #include<stdio.h>int main () {int is_run (int year), int year=1000;printf (" Leap year between 1000-2000 years is: \ n "), for (; year<=2000;year++) {if (Is_run ()) printf ("%d\n ", year);} return 0;} int Is_run (int year) {if (year%4==0&&year%100!=0| | year%100==0&&year%400==0) return 1;else return 0;}
This article is from "Love Technology Love Life" blog, please be sure to keep this source http://alick.blog.51cto.com/10786574/1708565
C Practice Small Code -20151012