LinYuan


私信TA

用户名:1533855037

访问量:28923

签 名:

c/c++ 从看懂到看开

等  级
排  名 99
经  验 8243
参赛次数 4
文章发表 49
年  龄 22
在职情况 学生
学  校 吉林建筑科技学院
专  业 计算机科学与技术

  自我简介:

努力拼搏 相信自己

 

0.0分

49 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

#include <stdio.h>
struct nian{
    int year, month, day;
};
int main(void)
{
    struct nian i;
    int j, t;
    int sum = 0;
    int a[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    scanf("%d %d %d",&i.year, &i.month, &i.day);
    for(j = 0; j < i.month - 1; j++){
        sum += a[j];
    }
    t = sum + i.day;
    if(i.month > 2){
        if(i.year % 4 == 0 && i.year % 100 != 0 || i.year % 400 == 0){
            t++;
        }
    }
    printf("%d\n",t);
    return 0;
    }
2024-02-05 21:36:46
#include<stdio.h>
 struct arr 
{
	int Year; //年
	int Monht; //月
	int Day; //日
}p;
int main()
{
	int a[13] = { 31,29,31,30,31,30,31,31,30,31,30,31 };//a[13]在我的编译器中会越界,当然也可以写a[12+1]留一个\n位置
	scanf("%d %d %d", &p.Year, &p.Monht, &p.Day);
	if (p.Year % 4 == 0 && p.Year % 100 != 0 || p.Year % 400 == 0)
	{
		int j = 0;
		p.Monht--;减去输入的最后一个月,输入的天数代替
		for (int i = 0; i < p.Monht; i++)
		{
			j += a[i];
		}
		j += p.Day;天数
		printf("%d",j);
	}
	else {
		int j = 0;
		p.Monht--;
		for (int i = 0; i < p.Monht; i++)
		{
			j += a[i];
		}
		j += p.Day;
		j--;//平年比闰年少一天
		printf("%d", j);
	}
		}
	return 0;
2023-09-18 20:19:00
#include <stdio.h>

int nian(int year) {
	return year % 400 ? ((year % 4) ? 0 : 1 ) : 1;
}

struct t {
	int year;
	int month;
	int day;
} ;

int main() {
	int w;
	struct t sc;
	int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	scanf("%d %d %d", &sc.year, &sc.month, &sc.day);
	for (int i = 0; i < sc.month - 1; i++) {
		w += months[i];
	}
	w += sc.day;
	if ((nian(sc.year) && sc.month > 2))
		w++;
	printf("%d\n", w);
	return 0;
}//为什么代码运行结果没问题但是过不了,显示答案错误
2023-08-10 00:49:06
#include<stdio.h>
struct date
{
	int year;
	int month;
	int day;
};
int mian()
{
	struct date a;
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int sum=0;
	scanf("%d%d%d",&a.year,&a.month,&a.day);
	if(year%400==0||year%4==0&&year%100!=0)//为闰年 
	{
		a[1]=29;//第二个月 
	}
	for(int i=0;i<a.month-1;i++)//如果3月,则天数为一月加二月的总天数,再加上三月的日期。 
	{
		sum=sum+a[i];// 加前面完全过了的月份 
	}
	sum=sum+a.day;//加上这个月的天数。
	printf("%d",sum);
	return 0; 
	

}请问这个为什么不对呀?
2023-03-27 22:38:25
else语句可以省略
2023-03-17 22:50:33
#include<stdio.h>
struct demo{
    int year;
    int month;
    int day;
};
int main(){
    struct demo a;
    scanf("%d%d%d",&a.year,&a.month,&a.day);
    int b[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    int sum=0,i;
    for(i=0;i<a.month-1;i++){
            sum=sum+b[i];
        }
    sum=sum+a.day;
    if(a.year%400==0||(a.year%4==0&&a.year%100!=0)){
        sum=sum+1;
    }
    printf("%d",sum);
    return 0;
}
2023-03-03 00:12:51
#include <stdio.h>

int main() {
	struct date {
		int year;
		int month;
		int day;

	};
	struct date a;
	int sum = 0;
	scanf("%d%d%d", &a.year, &a.month, &a.day);
	for (int i = 1; i <= a.month; i++) {
		if (i == a.month) {
			sum += a.day;
		} else {
			switch (i) {
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12:
					sum += 31;
					break;
				case 2:
					if ((a.year % 4 == 0 && a.year % 100 != 0) || a.year % 400 == 0)
						sum += 29;
					else
						sum += 28;
					break;

				case 4:
				case 6:
				case 9:
				case 11:
					sum += 30;
					break;
2022-12-18 23:31:35
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct str{
    int year;
    int month;
    int day;
};//注意这里的结尾处冒号
int isleapyear(int x);
void main()
{   
    int sum=0;
    struct str stu;
    scanf("%d %d %d", &stu.year,&stu.month,&stu.day);    
    int arr[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    for(int i=0;i<stu.month-1;i++)
    {
        sum+=arr[i];
    }
    if(isleapyear(stu.year))
        sum=sum+stu.day+1;
    else
        sum=sum+stu.day;
    printf("%d",sum);
    system("pause");
}
int isleapyear(int x)
{
    if(x%4==0 && x%100==0 || x%400==0) return 1;
    else
2022-09-07 10:22:36