代码改变世界

数组的几个举例

2009-09-16 22:16  youthjiang  阅读(255)  评论(0)    收藏  举报
#include <stdio.h>
#include 
<stdlib.h>

int main(int argc, char *argv[])
{
  
//Defatul salay data
  int nEmployee[10={2700,3200,27500,28500,29900,31000,32500,30000,26000};
  
  
int nIndex;
  
int nNewSalary;
  
int nSelection;
  
  
while(1)
  
{
     printf(
"=============================================================\n");
     printf(
"*Simple Employee Salary Management System*\n");
     printf(
"*1. Display employee salary              *\n");
     printf(
"*2. Modify employee salary               *\n"); 
     printf(
"*3. Quit                                 *\n");
     printf(
"=============================================================\n");
     printf(
"Please input your choose:");
     scanf(
"%d"&nSelection); 
     
     
if(nSelection ==1 ||nSelection ==2)
     
{
        printf(
"**Please input the employee number: ");
        scanf(
"%d"&nIndex);
        
        
if(nIndex <10)
        
{
            printf(
"**Employee number is %d  .",nIndex);
            printf(
"The Salary is %d\n",nEmployee[nIndex]);                 
        }
             
        
else
        
{
            printf(
"x The error Employee number !!!\n");
            exit(
1);    
        }
   
     }
   
     
     
switch(nSelection)
     
{
        
case 1:
             
break;
        
case 2:
             printf(
"** Please input new salary:");
             scanf(
"%d"&nNewSalary);
             nEmployee[nIndex]
= nNewSalary;
             
break;
        
        
case 3:
             exit(
1);
             
break;                  
                       
     }

     
     printf(
"\n");  
            
  }

  
  system(
"PAUSE");    
  
return 0;
}