标题:有哪个大哥大姐能帮我看看这道题?
只看楼主
caiqianxing
Rank: 2
等 级:论坛游民
帖 子:79
专家分:17
注 册:2010-4-8
得分:0 
dddddd
2010-04-13 14:18
一口三个汉堡
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:3
帖 子:155
专家分:525
注 册:2010-3-21
得分:0 
你可以自己改下啊,用goto语句或加个while啊

坚持做对的事情,而不是容易的事情。
2010-04-13 14:18
caiqianxing
Rank: 2
等 级:论坛游民
帖 子:79
专家分:17
注 册:2010-4-8
得分:0 
dddddd
2010-04-13 14:21
caiqianxing
Rank: 2
等 级:论坛游民
帖 子:79
专家分:17
注 册:2010-4-8
得分:0 
ddddd
2010-04-13 14:21
caiqianxing
Rank: 2
等 级:论坛游民
帖 子:79
专家分:17
注 册:2010-4-8
得分:0 
ddddddddd
2010-04-13 14:24
caiqianxing
Rank: 2
等 级:论坛游民
帖 子:79
专家分:17
注 册:2010-4-8
得分:0 
dddddddd
2010-04-13 14:25
caiqianxing
Rank: 2
等 级:论坛游民
帖 子:79
专家分:17
注 册:2010-4-8
得分:0 
ddddddddddddd
2010-04-13 14:39
brackenbo
Rank: 1
等 级:新手上路
帖 子:6
专家分:5
注 册:2010-4-9
得分:0 
程序没有错,结果也是对的,建议加while。
不会截图,只能将运行结果贴出:
Enter date (mm/dd/yy): 01/22/10
Dated this 22th day of January,2010.

Enter date (mm/dd/yy): 7/9/14
Dated this 9th day of July,2014.

Enter date (mm/dd/yy):
2010-04-13 14:49
雨夜星光
Rank: 4
等 级:业余侠客
帖 子:66
专家分:230
注 册:2009-11-25
得分:0 
#include<stdio.h>

main()
{
   
    int N,Y,R;
    int Flag=1;
    char x;
    while(Flag)
    {
        printf("请输入日期,yy/rr/nn\n");
        scanf("%d/%d/%d",&Y,&R,&N);   
        printf("Date this ");
        switch(R)
        {
        case 1:
            printf("%dst",R);
            break;
        case 2:
            printf("%dnd",R);
            break;
        default:
            printf("%dth",R);
            break;
        }   
        printf(" day of ");
        switch(Y)
        {
        case 1:
            printf("Jan");
            break;
        case 2:
            printf("Feb");
            break;
        case 3:
            printf("Mar");
            break;
        case 4:
            printf("Apr");
            break;
        case 5:
            printf("May");
            break;
        case 6:
            printf("Jun");
            break;
        case 7:
            printf("Jul");
            break;
        case '8':
            printf("Aug");
            break;
        case 9:
            printf("Sep");
            break;
        case 10:
            printf("Oct");
            break;
        case 11:
            printf("Nov");
            break;
        case 12:
            printf("Dec");
            break;
        default:
            printf("错误月份");
        }
        printf("    ,20%d\n",N);
        printf("是否重新输入Y/N:");
        do
        {
            getchar();
            scanf("%c",&x);               
            if(x==Y||x=='y')
            {
                Flag=1;
                break;
            }
            else
            {
                if(x=='N'||x=='n')
                {
                    Flag=0;
                    break;
                }
                else
                    printf("选择错误,请重新选择!\n");
            }
        }while(1);
    }
}

这个程序没有添加是否判断输入正确的功能,如果考虑的话,某一个月的日子,还有闰年都要计算,把一个月单纯的大于31的做法就是错误的,你有考虑2.29?4.31?……

C/C++交流群:65802335
2010-04-13 14:53
determine
Rank: 1
等 级:新手上路
帖 子:7
专家分:7
注 册:2010-3-31
得分:0 
void fun();
void main()
{
int i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
fun();
}
将上面程序写入 void fun()中就可以多次调用了
也可以这样在主函数中使用循环如char c; c=getchar();while(c!='#') { 函数体   c=getchar()}也可多次调用
2010-04-13 15:26



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-302671-1-1.html




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

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