C Practice Small Code-20151012

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.