The optimization of the prime number is obtained. To find a table of arbitrary order multiplication. Judging leap years

Source: Internet
Author: User

1. Print the prime number between 100~200
2. Output multiplication table
3. Judging the leap year between 1000---2000


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main ()
{
int count = 0;
int div = 0;
printf ("prime number between output 100-200 \ n");
for (int prime = 101; prime<=; prime+=2)
{
for (div= 2; div<=sqrt (prime); div++)
{
count++;
if (Prime%div = = 0)
Break
}
if (Div >sqrt (prime))
printf ("%d\n", Prime);
}
System ("pause");
return 0;
}





#include <stdio.h>
#include <stdlib.h>
int main ()
{
printf ("Output a n*n multiplication table \ n");
int n = 0;
scanf ("%d", &n);
for (int arr = 1; arr <= n; arr++)
{
for (int line = 1; line <= arr; line++)
{
printf ("%d*%d=%2d", arr, line, arr*line);
}
printf ("\ n");
}
System ("pause");
return 0;
}





#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int main ()
{
int year = 0;
printf ("Enter a year of 1000-2000 to determine if it is a leap year: \ n");
scanf ("%d", &year);
ASSERT (year >= && year <= 2000);
if (year%400==0| | (year%4==0&&year%100!=0))
printf ("%d is a leap year \ n", year);
Else
printf ("%d is not a leap year \ n", year);
System ("pause");
return 0;
}


This article is from the "11132019" blog, please be sure to keep this source http://11142019.blog.51cto.com/11132019/1751439

The optimization of the prime number is obtained. To find a table of arbitrary order multiplication. Judging leap years

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.