| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 323 人关注过本帖
标题:请各位高手帮忙看一下,哪里错了
取消只看楼主 加入收藏
zhouxiangron
Rank: 2
等 级:论坛游民
帖 子:19
专家分:20
注 册:2010-7-9
结帖率:42.86%
收藏
已结贴  问题点数:20 回复次数:0 
请各位高手帮忙看一下,哪里错了
这几天学到了结构体,写了代码,但是出错,请各位给我看看:
程序代码:
#include <stdio.h>
#include <string.h>
struct data
{
    int year,day;
    int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
}find;
void yearmonthday()
{
    int sum,i,j;
    printf("please input the year month and day:\n");
    scanf("%d %d %d",&find.year,&i,&find.day);
    if(find.year%4==0&&find.year%100==0||find.year%400==0)
    {find.month[1]=29;}
    for(j=0;j<i;j++)
    {
        sum=sum+find.month[j];
    }
    sum=sum+find.day;
    printf("the day is %d",sum);
}
void yearday()
{  
    int i,sum=0;int month1,day1;
    printf("please input the year and day:\n");
    scanf("%d %d",&find.year,&find.day);
    if(find.year%4==0&&find.year%100==0||find.year%400==0)
    {find.month[1]=29;}
    month1=find.day/30;
    day1=find.day%30;
    printf("month=%d,day=%d",month1,day1);
   
}
void main()
{  
    int switches;
    printf("please input the case:\n");
    printf("1.please input the year,day,give your month day.\n");
    printf("2.please input the year month day give your data.\n");
    printf("plase chose (1\2):\n");
    scanf("%d",&switches);
    switch(swithes)
    {
    case 1:yearday();break;
    case 2:yearmonthday();break;
    default:printf("error!\n");break;break;
    }
   
}

第一个函数是:给定年、月、日,求天数。
第二个函数是:给定年和天数求日月,第二个函数也不会写。
各位高手帮帮忙啊!
搜索更多相关主题的帖子: 结构体 
2010-08-10 08:39
快速回复:请各位高手帮忙看一下,哪里错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023506 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved