各位看看哪出了问题?无法输出天数。
程序代码:
// ConsoleApplication2.cpp : 定义控制台应用程序的入口点。 // #include <stdio.h> #include<stdlib.h> #include<string.h> #include<time.h> int main() { char id[] = ""; printf("enter your id:"); scanf("%s", &id); printf("you born on %c%c%c%cyear%c%cmonth%c%cday\n", id[6], id[7], id[8], id[9], id[10], id[11], id[12], id[13]); long nowyear, days, i,T; char a[12] = { 31,29,31,30,31,30,31,30,31,31,31,30 }; printf("now is:"); T = id[10] * 10 + id[11]; days = id[12] * 10 + id[13]; scanf("%d", &nowyear); if (nowyear % 4 == 0 && nowyear % 100 != 0) { char a[12] = { 31,29,31,30,31,30,31,30,31,31,31,30 }; } else { char a[12] = { 31,28,31,30,31,30,31,30,31,31,31,30 }; } for (i = 0; i < (id[10] * 10 + id[11] -1); i++) days += a[i]; printf("your birthday is the %l days.\n", days); system("pause"); return 0; }