c語言如何比較出生年月?
可參考以下示例程序:
#include<stdio.h>struct s{int year;int mon;int day;}javaman,cpcs;int main(){int i,n;printf("輸入比較的組數:\n");scanf("%d",&n);for(i=0;i<n;i++){printf("輸入javaman和cpcs出生年,月,日:\n");scanf("%d,%d,%d",&javaman.year,&javaman.mon,&javaman.day);scanf("%d,%d,%d",&cpcs.year,&cpcs.mon,&javaman.day);//比較大小if(javaman.year<cpcs.year)printf("javaman \n");else if(javaman.year>cpcs.year)printf("cpcs\n");else{if(javaman.mon<cpcs.mon)printf("javaman\n");else if(javaman.mon>cpcs.mon)printf("cpcs");else{if(javaman.day<cpcs.day)printf("javaman\n");else if(javaman.day>cpcs.day)printf("cpcs\n");elseprintf("same\n");}}}return 0;}