ÇÁ·Î±×·¡¹Ö

 3206, 1/161 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   ¤Ñ.¤Ñ
   ¹¹°¡ À߸øµÈ°ÇÁö ºÁÁÖ¼¼¿ä

http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_programming&no=33 [º¹»ç]


visual c++¿¡¼­ Çߴµ¥ ¿À·ù 14°³Á¤µµ ¤Ñ.¤Ñ

#include <stdio.h>

#define MAX 100
#define YES 1
#define NO 0

long income[MAX];
int month[MAX],day[MAX],year[MAX];
int x,y,ctr;
int cont;
long month_total, grand_total;
void main(void);
int display_instructions(void);
void get_data(void);
void display_report(void);
int continue_function(void);



void main(void)
{
        cont=display_instructions();
        if(cont==yes)
        {
                get_data();
                display_report();
        }
        else
                printf("\nProgram aborted by user!\n\n");
}




int display_instructions(void)
{
        printf("\n\n");
        printf("nThis program enables you to enter up to 99 peple\'s");
        printf("\nincomes and birthdays. It then prints the incomes by");
        printf("\nmonth along with the overall income and overall average.");
        printf("\n");
        cont= continue_function();
        return (cont);
}

void get_data(void)
{
        for(cont=YES,ctr=0;ctr<MAX && cont==YES; ctr++)
        {
                printf("\nEnter information for Person %d", ctr+1);
                printf("\n\tEnter Birthday: ");

                do
                {
                        printf(\n\tMonth (0 - 12) : ");
                        scanf("%d", &month[ctr]);
                }while (month[ctr} < 0 || month[ctr] > 12);
                
                do
                {
                        printf("\n\tDay (0 - 31): ");
                        scanf("%d", &day[ctr]);
                }while (day[ctr] < 0 || month[ctr] > 31);
                
                do
                {
                        printf("\n\tYear (0 - 1997): ");
                        scanf("%d", &year[ctr]);
                }
                while (year[ctr] < 0 || year[ctr] > 1997);

                printf("\nEnter Yearly Income (whole dollars): ");
                scanf("%ld", &income[ctr]);
                
                cont = continue_function();
        }
}

void display_report()
{
        grand_total=0;
        printf("\n\n\n");
        printf("\n                SALARY SUMMARY");
        printf("\n                ===============");

        for(x=0; x<=12; x++)  
        {
                month_total=0;
                for(y=0; y<ctr; y++)
                {
                        if(month[y]==x)
                                month_total+=income[y];
                }
                printf("\nTotal for month %d is %ld", x, month_total);
                grand_total+=month_total;
        }
        printf("\nReport totals: ");
        printf("\nToTal Income is %ld", grand_total);
        printf("\nAverage Income is %ld", grand_total/ctr);

        printf("\n\n* * * End of Report * * *\n");
}

int continue_function(void)
{
        printf("\n\nDo You Wish to continue? (0=NO/1=YES): ");
        scanf("%d", &x);

        while(x<0 || x>1)
        {
                printf(\n%d is invalid!",x);
                printf(\nPlease enter 0 to quit or 1 to continue: ");
                scanf("%d",&x);
        }
        if(x==0)
                return(NO);
        else
                return(YES);
}

  Hit : 4447     Date : 2003/09/09 05:11



    
3206   SNSÇØÅ·ÀÌ µÇ³ª¿ë? µµ¿ÍÁÖ¼¼¿ä ¤Ð¤Ð¤Ð [2]     ÇÑä¹Î
02/28 332
3205   Ä¡Æ®¿£Áø °í¼öºÐ °è½Ç±î¿ä[1]     rjsdudals123
02/15 184
3204   ¿À·ù Á» ã¾ÆÁÖ¼¼¿ä [1]     marunim
05/30 915
3203 ºñ¹Ð±ÛÀÔ´Ï´Ù  124     minsub87
08/17 1
3202   c¾ð¾î segmentation fault:11 ¿À·ù Áú¹®µå¸³´Ï´Ù![2]     leebk1124
05/21 2004
3201   C++ÇÔ¼ö°ü·Ã Áú¹®ÀÌ¿¡¿ë!![3]     1999dylee
05/11 1839
3200   ÆÄÀ̽ã Áö¹® µå¸³´Ï´Ù.[1]     kksh1107
04/24 1578
3199   ¸®¹ö½ÌÀÇ ¼¼¹ø¤Š ²É - ¿ª¶û-     nninni79
04/20 2281
3198   ´Þ°í³ª ¹®¼­ ½©ÄÚµå[1]     ghjk645
03/24 1603
3197 ºñ¹Ð±ÛÀÔ´Ï´Ù  c¾ð¾î ¼Ò¼ö °ª     adwefq
04/29 0
3196   C¾ð¾î ¼Ò½ºÁú¹®ÀÔ´Ï´Ù![5]     an0088
01/05 5109
3195   C++ /// ºôµå ¿¡·¯ ¤Ð¤Ð[1]     guichanta
08/23 2391
3194 ºñ¹Ð±ÛÀÔ´Ï´Ù  c¾ð¾î µµ¿ÍÁÖ¼¼¿ä¤Ð¤Ð     su6339
04/06 0
3193   ÇØÅ·À» ¹è¿ì·Á°íÇϴµ¥[3]     zoodem04
03/26 4178
3192   c¾ð¾î¸¦ ¹è¿ì°í½Í¾î¿ä ![7]     dwc07238
02/11 4058
3191   ½ºÅÃÀÌ ½×ÀÌ´Â ¹æÇâ¿¡ °üÇؼ­!![1]     hackxx123
12/10 3510
3190   ÇØÅ·Åø¿¡¼­ ip ¾øÀÌ Çϵ忡 ½É´Â°Å¿¡´Â ¾î¶²°Ô ÀÖÀ»±î¿ä?[2]     aowlrgmlals
11/27 4268
3189   C¾ð¾î Çϴµ¥ double ½Ç¼ö¸¦ ³ÖÀºµ¥ ÀÚ²Ù 0.0ÀÌ ³ª¿Í¿ä[2]     fatou10336
11/20 3720
3188   dumpcode.h ÀÌÇØÁ» µµ¿ÍÁÖ¼¼¿ä .[1]     cm6418
11/06 3699
3187   c¾ð¾î ¾Ë°í¸®Áò Áú¹®ÀÔ´Ï´Ù.[3]     alstn8150
10/12 3722
1 [2][3][4][5][6][7][8][9][10]..[161]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org