#includestdio.h
創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比宜黃網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式宜黃網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋宜黃地區(qū)。費用合理售后完善,十多年實體公司更值得信賴。
#define?N?10
int?age(int?x)
{
if(x==1)?return?N;
return?age(x-1)+2;
}
int?main()
{
printf("%d\n",age(5));
return?0;
}
#includestdio.h
#includestdlib.h
int?idage(char?*str)
{?int?i;
char?idcard1[100];
int?year;
int??year;
for(i=0;i=3;i++)
{
idcard1[i]=str[i+6];
}
idcard1[i]='\0';
year=atoi(idcard1);//atoi函數(shù)c語言庫函數(shù)將字符串轉(zhuǎn)換為整數(shù),也就得到年份;
age=2015-num;
return?age;
}
int??idsex(char?*str)
{
if(str[16]%2==0)
return?-1;
if(str[16]%2!=0)
return?1;
}
void?main()
{char?idcard[100];
int??sex;
int?age;
gets(idcard);
sex=idsex(idcard);
if(sex==1)
printf("男\(zhòng)n");
if(sex==-1)
printf("女\n");
idage(idcard);
age=idage(idcard);
printf("此人今年是%d歲\n",age);
}
得到年齡的函數(shù)還可以寫成:
int?idage(char?*str)
{?int?i;
char?idcard1[100];
int?year=0;
for(i=0;i=3;i++)
{
idcard1[i]=str[i+6];
}
idcard1[i]='\0';
for(i=0;i=3;i++)
{
year=year*10+idcard1[i]-48;//得到年份;
}
age=2015-year;
return?age;
}
struct Date{
int year;
int month;
int day;
};
Date * fun(Date *date){
Date today;
today.year = 2013;
today.month = 7;
today.day = 1;
Date age;
age.year = today.year - date-year;
age.month = today.month - date-month;
age.day = today.day - date-day;
return age;
}
int main(){
Date me;
me.year = 1980;
me.month = 6;
me.day = 12;
Date * age = fun(me);
printf("%d%d%d",age-year,age-month,age-day);
return 0;
}
#includestdio.h
int?main()
#includestdio.h
int?main()
{
int?number();
printf("%d",number(5));
}
int?number(int?n)
{
int?age;
if(n==1)
age=10;
else
age=number(n-1)+2;
return?age;
}
熱心