Blue Bridge Cup practice - induction training

A title:
Title: The first few days

2000 January 1, is the first day of the year.
Then, in 2000, May 4, the first few days of the year?

Note: You need to submit is an integer, do not fill out any extra content.

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int i, y, m, d, t = 0;
	int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	scanf("%d %d %d",&y,&m, &d);

	for (i=0; i < m; i++)
		t = t + month[i];
		
	t += d;
	
	if((y % 4) == 0){				//判断是否为闰年
		if ((y % 400) == 0){
			t +=1;
		}
	}
	
	printf("%d",t);
	
	return 0;
}

Topic two:

Description of the problem
to a given radius r of the circle, the area of circular.
Input format:
input contains an integer r, represents the radius of the circle.
Output format:
output line, comprising a real number, rounded to 7 after the decimal point indicates the area of a circle.
Description: In this problem, the input is an integer, but the output is a real number.

For the problem of real output, be sure to look at the requirements of real output, such as required in this question after seven decimal places, then your program must be strictly output seven decimal places, too much or too little output of decimal places are not , it will be considered an error.

The real question is if the output is not specified, rounding is performed by rounding.

Input Sample
4
Sample Output
50.2654825
data size and Conventions
1 <= r <= 10000.
Prompt
this question of high precision , please note that the value of π should take a more accurate value. You can use constants to represent π, for example PI = 3.14159265358979323, mathematical formulas may be used to seek π, such as PI = atan (1.0) * 4 .

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int r;
	double s;
	const double PI=3.14159265358979323;				//对精度要求高,不能使用3.14代替
	
	scanf("%d",&r);
	s = PI * r * r; 
	printf("%.7lf",s);					//注意这里的输出
	 
	return 0;
}

Guess you like

Origin blog.csdn.net/weixin_44566432/article/details/88413178