第1題、 #include<stdio.h> int main() {git
int yyyy,mm,dd;// printf("Enter a date(mm/dd/yyyy)"); scanf("%d/%d/%d",&mm,&dd,&yyyy); printf("You Enter the date %d%d%.2d",yyyy,mm,dd); return 0;
} 第2題、 #include<stdio.h> int main () {ide
int number ,mm,dd,yy; float price; printf("Enter item number:"); scanf("%d",&number); printf("Enter nuit price:"); scanf("%f",&price); printf("Enter purchase date (mm/dd/yy)"); scanf("%d%d%d",&mm,&dd,&yy); printf("Item\tunit Price\Purchase Date\n"); printf("%d\t$%4.2f\t\t%-.2d/%.2d/%d\n",number,price,mm,dd,yy); return 0;
}ui
第3題 #include<stdio.h> int main () {3d
int gsi,group,publisher,item,check; printf("Enter ISBN:"); scanf("%d-%d-%d-%d-%d",&gsi,&group,&publisher,&item,&check); printf("GSI Perdix:%d\n",gsi); printf("Group identifier:%d\n",publisher); printf("publisher code:%d\n",publisher); printf("Item number:%d\n",item); printf("Check code:%d\n",check); return 0; }
第4題 #include<stdio.h> int main() {code
int number1,number2,number3; printf("Enter phone number[(xxx)xxx-xxxx]:"); scanf("(%d)%d-%d",&number1,&number2,&number3); printf("You entered:%.3d.%.3d.%.4d\n",number1,number2,number3); return 0;
} 第7題 #include<stdio.h> int main () {it
int number printf("Enter a two-digit number:"); scanf("%d",&number); printf("The reverse is:%d\n",number); return 0;
}io
第9題(1) #include<stdio.h> int main () {class
int d,i1,i2,i3,i4,i5,i6,j1,j2,j3,j4,j5,total; int first_sum,second_sum; printf("Enter the first (single)digit:"); scanf("%d",d); printf("Enter first group of five digits:"); scanf("%1d%1d%1d%1d%1d",&i1,&i2,&i3,&i4,&i5); printf("Enter first group of five digits:"); scanf("%1d%1d%1d%1d%1d",&j1,&j2,&j3,&j4,&j5); first_sum=d+i2+i4+j1+j3+j5; second_sum=i1+i3+i5+j2+j4; total=(first_sum*3+second_sum); total=9-(total-1)%10; printf("check digits:%d",check); return 0;
}date
(2) #include<stdio.h> int main() {float
int d,i1,i2,i3,i4,i5,j1,j2,j3,j4,j5,total; int first_sum,second_sum; printf("Enter the first 11 didits of UPC:"); scanf("%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d",&d,&i1,&i2,&i3,&i4,&i5,&j1,&j2,&j3,&j4,&j5); first_sum=d+i2+i4+j1+j3+j5; second_sum=d+i1+i3+i5+j2+j4; total=(first_sum*3+second_sum); total=9-((total-1)%10); printf("Check digits:%d\n",total); return 0;
} 第10題 #include<stdio.h> int main () {
int i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,total; int first_sum,second_sum; printf("Enter the first 12 digits of EAN:"); scanf("%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d",&i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8,&i9,&i10,&i11,&i12); first_sum=i2+i4+i6+i8+i10+i12; second_sum=i1+i3+i5+i7+i9+i11; total=(first_sum+second_sum); total=9-((total-1)%10); printf("Check digit:%d\n",total); return 0;
}