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