薪水计算实战
姓名年龄连接实战
薪水计算实战
#include
#include
int main(){
int sum,salary;//记录工资
do{
printf("请输入工资:");
scanf("%d",&salary);
//开始计算
if(salary<=5000){
sum=salary;
}
else if(salary>5000&&salary<=8000){
int tax=(salary-5000)*0.1;
sum=salary-tax;
}
else if(salary>8000&&salary<=10000){
int tax=(salary-8000)*0.15+3000*0.1;
sum=salary-tax;
}
else if(salary>10000){
int tax=(salary-10000)*0.2+2000*0.15+0.1*3000;
sum=salary-tax;
}
printf("到手工资:%d\n",sum); }
while(1);
return 0;
}
姓名年龄连接实战
#include
#include
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
//输入年龄 20
// your age is twenty;
int main(int argc, char *argv[]) {
int age=0;
//保存个位数 one two (字符串数组)用 char* 数组名[]={初始值1,初始值2.初始值3,...初始值n};
char* gewei[]={" ","one","two","three","four","five","six","seven","eight","nine"};
// 保存十位数
char* shiwei[]={"twenty","thirty","fourty","fifty","seventy","eighty","ninty"};
//保存十到十一
char* temp[]={"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
do{
printf("请输入年龄:");
scanf("%d",&age) ;
char* name;//保存每次取出的字符串 ,此处name是一个指针,本编译器里面它不能赋初值
if(age<10){
name=gewei[age];
}
else if(age>=10&&age<=19){//获取个位数
int index=age%10;
name=temp[index];
}else{
//获取十位数
int s=age/10;
//获取个位数
int g=age%10;
char* sstring=shiwei[s-3];//string 时字符串,可以去了解一下
char* gstring=gewei[g];
printf("your age is %s-%s\n",sstring,gstring);
return 0;//程序还未运行完毕就提前结束 ,此处也可以使用break
}
printf("your age is %s\n",name);}
while(1);
return 0;
}