0 like 0 dislike
1.1k views

Write a program that prompts the user to enter two dates and then indicates which date comes earlier on the calendar (m/d/yyyy):
 Sample input:

3/6/2008
5/17/2007

Sample output:

5/17/2007 is earlier than 3/6/2008

 

Sample input:

3/6/2007
5/17/2008

Sample output:

3/6/2007 is earlier than 5/17/2008

 

Sample input:

3/6/2007
3/6/2007

Sample output:

Same day!

 

[Exercise] Coding (C) - asked in C
ID: 22673 - Available when: Unlimited - Due to: Unlimited

edited by | 1.1k views
0 0
Called for Help

56 Answers

0 like 0 dislike
Hidden content!
#include * *** *

void END(int A[], int B[]){
** * **** *** * *** ** * ** is earlier than * * * ** A[1], A[2], A[0], B[1], B[2], B[0]);

}



int BOS(int A, int B){
* *** *** *** ** * ** ** ** return 1;
** **** * * *** ** * if(A<B) return 0;
****** * ** ****** * ** *** return -1;

}



int main(void){
* * * *** ** * ** * * ** one[3], two[3], i;


*** *** ** * ******** ** * * * ***** **** * ** ** * * * * ** ***
** * * ** ** * * * * * * * * &two[1], * * *** ***** * *


* * ** **** * *** * ****** * * i<3; i++){
* ** **** ** * * * * * ** ** * ****** * * two[i])==1){
** ** * * * * * ** **** **** * * * ** * **** * * * * * ** *** ** *** one);
**** * ** * * *** * *** * * * * * * *** * ****** * *
***** ** * * * * *** ** **** * *** *** if(BOS(one[i], two[i])==0){
**** * * ** * **** * *** * * *** * * ** * ** ** ****** ***** *** two);
*** *** ** *** *** ** ** *** ** * ** * * ** * * ** ** * *
* ** **** ** * * *


* * ** ** *** **** *** *** * ***** * *** * ** * * ** * ***** *** day!");
* ***** * ** ** ** **** *** 0;

}
answered by (-581 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

#include <string.h>



int main (){
** * * ** * * * **** y , m ,d ,y2,m2,d2 ;
****** **** * * * * ** *** * * ****** *** **** * *** *
* ** *** ** * **** * * ***** * ****** * **** ** **********
*** ** * * * ** * (y2 >y){
* ** ** * *** ***** * ** * * **** *** * * ("%d/%d/%d is earlier than %d/%d/%d",d,m,y,d2,m2,y2);
* * * ** *** *** * *
* ** * *** if (y > y2){
******** ********* * ** ***** ** * **** * * * * * ("%d/%d/%d is earlier than * * * * *
**** * * * **** *
* ** * * * * ***** ** * if(y == y2){
** ** * ****** * ******** ** ** ** * * * * (m2 > m){
* ** * *** * * * * * * * *** * ** * ** * * * * * ** * ("%d/%d/%d is earlier than %d/%d/%d",d,m,y,d2,m2,y2);
* * ** *** ****** ** * **** ** * *
**** **** * **** * * *** * ** ** * * ** *** ** * if (m >m2){
* * ***** * * *** ** * ** *** ***** * * **** * ** *** * *** * ("%d/%d/%d is earlier than %d/%d/%d",d2,m2,y2,d,m,y);
*** **** *** * ** *** ** ** ** ****
* * *** ** * ** *** * * * * ** ** * * * if(m == m2){
**** **** ***** * * * * * *** ** **** * * *** * * ** ******* *** ***** * > d){
*** * ** * * ** ***** * * **** * * * * *** *** ** * * ** * *** ** * * * *** * ** ("%d/%d/%d is earlier than *** * ***** * *
* * * ** * * **** * * **** * * *** * * ****** * ***** * ***** * * *
** * *** * * ***** * **** ** ** * * *** *** * * **** * *** * * ** if (d > d2){
** * **** ** **** * * ***** *** * * * * ** * * **** * * **** *** * * *** * ** *** * * ("%d/%d/%d is earlier than %d/%d/%d",d2,m2,y2,d,m,y);
**** **** *** ***** ** ** * * * ***** * ** ** * *** * * * * **** ** *
* * ** ** * ** * * * * *** * * * * * * * *** * ** ** * ******* if(d == d2){
* * * * ** * * * ** ***** *** ** ** ** * * **** ***** ** ***** ** * * * *** * * *** * ** * ** ** * **** * * * ("Same day!");
*** *** * * ** ** * ** * ** ** *** * *** * ** * * * *
**** * * ** * ** * ** * * * * ****** ** *
* ** ** * * ** ***
** ** ** *** * ** *
* ** * * * ** * * * *** * 0 ;

}
answered by (-136 points)
0 like 0 dislike
Hidden content!
#include * ** * ** * *



int main()

{



int ** *****

int n[10];


* ** * ** **** **** **** * * ***
* * * * ** * *** * ** * * ** ** *





if(a==d ***** *** b==e ** * c==f){
* * ** * ** **** ** ** **** * * **** *

return 0;

}


** ** *
**** ** * * ***** ** * ****** is earlier than * ** *** * * * ** **
** **** * **** * *** **** if(c<=f * * * *** a<d)
* ***** * ** **** ** **** ** is earlier than * * *** * **
*** **** ** ** * * ***** **** * * ** * * * *** b<e * ** * a<=d)
* * ** ***** ** * ******* *** *** * ** * * * **** *** * * *** * is earlier than * * ******* ** ** * *


* * * * ** * * ** * ** ****
********* * * ********* * ** * * *** * ** ****** * ** is earlier than *** * ******* *** **





}
answered by (-368 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main(void)

{
* ** * * ** * * *** * * * m1, m2, d1, d2, y1, y2;
** *** * *** ** * ** * * * * * * ***** * &m1, &d1, &y1);
* **** * * * ** ** *** * * **** *** * ** * &m2, &d2, &y2);


** *** * * *** * (y1<y2)
* ***** * *** ** * * ** ******* * ** * *** ** * * * is earlier than * * ** * * d1, y1, m2, d2, y2);
* * * ** *** * ** * * if (y1==y2)
* * **** * ** ** ** *
* *** ** ** *** **** ** **** *** *** * (m1<m2)
*** * * ** ******* * * * * * * ** * * ** *** *** ** ***** *** ** is earlier than *** ** ** d1, y1, m2, d2, y2);
* * * ** *** * ** * ** * ***** * * *** * * **** ** ** if (m1==m2)
** *** * * * * * * * * *** * ** *** * * * *
*** * *** *** ** ***** ** * *** ** * * * ***** *********** * * ** ** * * * (d1<d2)
*** * ** * *** * * * *** ** * *** *** ** ** ** * * * * * ** * *** ** ** * ** *** * **** ** * is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
***** **** ** ** ** * * * ** * * *** * *** *** ** * * * * ** * * * if (d1>d2)
* * ***** ****** *** * ** * * * * ** * ** ** ** *** ** ** * * ** * ** * ******* * ** * ***** * ** ** is earlier than * ** ***** * * d2, y2, m1, d1, y1);
* ** *** * *** * ** * * ** ** * *** * ** * **** ** ** * * **
* * **** **** * * ** * * ** * ** *** * ** * * * * **** * ** * * * * * * * * * ** * *** * * day!");
*** *** ** * * ** ** * **** ** * * ** **
* * ** *** * * * * * * * * **** ** *
* ** * * ** * * ** * * * ** ** ***** ** * * * * * * * * * **** is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);
****** ***** ***** **** *
*** ** ** **** ******* *********
** * *** ** * * ** * * *** ** ** * * * * * *** ** * ** is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);


***** *** * * * * ** * 0;

}
answered by (38 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

#include <string.h>



int main (){
* *** ** * ***** * ***** y , m ,d ,y2,m2,d2 ;
* * ** ***** * * ** * * * * ** ** * ** * * * *
* ** **** ** * * * * * ****** ****** **** *** ** * **
****** * * * * (y2 >y){
** * * * * * * * *** *** * ** ** ** * * * ("%d/%d/%d  is earlier than * * ** *
****** *** * * * *** ***
* * ** * * * **** * * * *** if (y > y2){
* **** ** * * * * * ** * * * *** * *** ("%d/%d/%d  is earlier than %d/%d/%d",d2,m2,y2,d,m,y);
**** ** * * * *
* ** * * * * * **** * if(y == y2){
******** *** * ** * ****** *** ** * * * (m2 > m){
* * * **** * * **** **** * ** * * *** *** * * * * ** * *** ** ** * ("%d/%d/%d  is earlier than %d/%d/%d",d,m,y,d2,m2,y2);
**** * *** ** ** * ** * * * * *** *
* * * ** ** * * * *** * * * * ** * **** ****** if (m >m2){
* * * * * * * *** **** * ** * * * * * * ** * ** * ** * *** ** *** * ("%d/%d/%d  is earlier than ** * * * * ** *
***** ** ** ** * * * ** **** * *** * *
* * ** ** * * * * ** * *** *** ** **** *** if(m == m2){
* *** * * * * ** ** * **** * * * * *** * ** *** ** * * * * * > d){
*** * *** ** ** *** *** * * *** * * * * ******* ** * * ** ** ***** ** * ** * * ** *** ("%d/%d/%d  is earlier than * ** * * ** *
*** * ** * * * ** * ****** ** ** ** ** * ** **** ** ** * * ** *** *
* ** ** ** ** * ** ** * ** ** *** ***** **** * * ** ** ** **** if (d > d2){
**** ** * * *** * * ** ** ** ** * *** ** * * **** *** ** **** * ** ** *** * ("%d/%d/%d  is earlier than *** * **** ** **
*** ** *** *** ***** * * * * *** ** ** ** **** ** ** *
* ***** * * * **** * * * ******* ******** *** * ** * * * * * * ** ** ** if(d == d2){
** *** **** * * * ** ** * * * * ** **** ** **** ** ** ** ******* * * ***** * ** * ** ** ******* * * ("Same day!");
******* * **** * * * * * * ** * * ****** * ** ** * *** * *
* * *** ** * * * *** * ** * * *** ** * *
**** ** *** * * * **
*** * * * **********
******** *** * *** * 0 ;

}
answered by (-136 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

int main()

{

    int year1,year2,month1,month2,day1,day2;
* **** * * **** ** ** * * ** * * *** ** * * * * ** **** * ***
* * **** * ** * * *** ** * * * ** * * * * ** * * * * *
***** * ****** * *** * * ** *** ** * ** *
* ****** *** * **** * * ***** *** * * * * *** **** ***** * is earlier than **** ** ** ***** ********** * * *

    else if(year2<year1)
* * *** * * **** *** ** * * * *** *** * *** *** ** is earlier than ** **** * ** * ** * * * *

    else

    {
* ** * ** ** **** * ** * ****** * * **** ** *** * *** * * *
*** * * * ** ** * * ** * ******* * * *** * ** * ** * * * *** * * ** ***** * * *** is earlier than * *** * *** ********* * * * *
* * * * * * * ** ** *** * *** *** * ** * if(month2<month1)
* ** * * * *** *** * ** * * ******** * * * **** ** * **** * ** *** * * ** ** ** is earlier than ** *** *** * ** * *** * *** *
* ** * ** *** * * * * * * * *** ** ** ** *** * * * **
***** * * ** ** * * * * * ****** ** * ** **** **
* ** ***** * ** *** *** * ** * * **** ** **** * * ***** *** **** * * *** ** * * ***
** *** ** ** * * * * ** * * * * *** * * ** ** ** ** ** * * * * * *** * * * ** * ** ** is earlier than ** * * * * ** * ** **** * * **
***** **** * * * * * * * * * ** * ** * *** *** ** * if(day2<day1)
* * ** * ******* * * ***** * *** * * * *** * * *** ** * * ** * ** * **** * *** * * * * * * ** **** **** ** is earlier than * * * * ** * * **** * ** ****
** * * * *** * * * ***** *** ** ** **** ** * * *** **
* **** * *** * *** *** * ** ** * * * ***** * ***** **** * ** ********* ** ** *** *** * ** ** * * day!");
* * *** ** ** *** *** **** ** ** ** *

    }

    
* **** ** * * * *** ** **** 0;

}
answered by (-384 points)
0 like 0 dislike
Hidden content!
#include * ** *



int main()

{



int * **** **

int n[10];


* *** ******** ** * ***** ** ** **
** ***** * * **** ** * *** *** * * * *


** * ****
*** * * * * * ** ** ** * * is earlier than * **** * * * ** *
* * ** ** *** *** if(c<=f *** * * a<d)
* *** *** ** ** ** **** ** ** * * is earlier than * ** ** * ** ** *
** *** * *** ** *** if(c<=f * * * ** **** b<e * * * a<=d)
* **** ** *** ** * ** * * ** ** ****** ** * ** * * ** ****** *** * is earlier than *** * * *** * ***


** ** ***** **** ** **** * *
** * ** * * * * * **** *** ** *** * ******* ** * * is earlier than ****** * * * *** *







if(a==d * * ** * b==e *** ** * c==f)
** * * **** ** * * ***** * * **** * *



}
answered by (-368 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>





int main()

{

int m1,m2,d1,d2,y1,y2;


** ** * * ** * * ** *** ** * *
*** * **** ** ** * ** ** * * ** **





if (y1<y2)
* ** **** * * * * * * ** * ** * is earlier than * * * *** **** * **

 else if (y1>y2)
* * ** ****** * ** ** ** **** ** * is earlier than %d/%d/%d",m2,d2,y2,m1,d1,y1);



 else if (y1==y2)


* ** *** **** **
* ***** ** * **** ** * * * * ** * ** ** * * * (m1<m2)
* ** * **** ** * **** * * *** ** ******* **** * ****** is earlier than * * ** * ** *** *
**** * * ** *** ** ** ** ******** * if (m2<m1)
* *** * * * *** ** *** ** ** ** ** * * ** * ** * ** is earlier than * * ** * * * ** ** ***
* * * * * ** * *** * ** **** ** **** **** ** if (m2==m1){
** * **** **** ***** * * ** ** ** * ***** * * * ** * ****** * ** * *** * * ******* * ** ****** (d1<d2)
**** ** * *** * **** ****** * ** * ** ** * * * **** * * *** * * * **** *** * *** ** * **** ** * ** ***** is earlier than ** * *** * * ****
* * **** *** ** ** ** **** * *** ***** ** * * * * * * * ** *** * * ** * if (d2<d1)
** * * * * ** * ** ** * * * *** ** *** ** ** *** * *** *** *** *** ****** * * ** * is earlier than %d/%d/%d",m2,d2,y2,m1,d1,y1);
** * * ** * * **** * * **** **** * * * *** * *** * ** * * * * * * ** * * if(d1==d2)
***** *** ** ** **** *** ** * ** * * * ** ****** * * * ***** * * * ***** ***** * * ***** *** **** * * * * * ***** *** day!");
*** * ** ** * *


** * * * ** ** ** *

return 0;

}
answered by (-34 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>



int main()

{

int month1, month2, date1, date2, year1, year2;
***** * ** * *** * ** * * *** * ** **** * ** *
* *** * ***** * ** ** ** * * * * *** ** *** * **



if(year1>year2)

{
** **** * ** ** * *** ** * *** * ** * is earlier than %d/%d/%d",month2,date2,year2,month1,date1,year1);

}

else if(year2>year1)

{
*** ***** *** * **** **** *** * **** * is earlier than %d/%d/%d",month1,date1,year1,month2,date2,year2);

}

else if(year1=year2)

{
**** * ** * ** *** **** * * * * *** * * *
* ** *** * ****** * **** * ** **
** * * * *** * * * ***** ** ** ****** * **** *** * ** *** ** * ** **** ** ** ***** * is earlier than %d/%d/%d",month2,date2,year2,month1,date1,year1);
** ******* ** *** * **** ** ** * * *
*** ** *** * **** * **** ** * **** ** ********** * * if(month2>month1)
** **** * **** ***** ******** ** *
* * *** *** * *** * ** ***** *** * ** ** **** ** * * ** * * ** ** **** is earlier than *** *** * ** *** * * * ** * *
* * ** * * **** *** * ** *** * *** ** * *
****** **** * ** *** * ** * * * * **** ** * * ** if(month1=month2)
* ** ** * ** * * * * * * * ** * ** ** *******
******** * * * ** ** * * * * * ** * * ******** * * ***** * * * ** * * *******
** ** * * * ** * **** * ** *** ** * ** * ** ** * *
* ** *** *** ** * ** ** * **** * **** *** * ** *** ** *** * ** * ******* **** * **** * * * *** *** *** is earlier than %d/%d/%d",month2,date2,year2,month1,date1,year1);
* * ** ** * * ** * * ***** *** *** * ***** * * ** ** * * *** *
** **** * **** * ***** ** * ** * * ** * * * * * * ** * * ** * * if(date1<date2)
* ** * **** * *** **** *** * * *** * **** ** ** * ** ** *** * * *** * ** ** *** ** * **** is earlier than %d/%d/%d",month1,date1,year1,month2,date2,year2);
** *** ** ** * **** *** * * * * ** * * ******* ** ** *** **** ** * * if(date1=date2)
* * ***** *** ** ** * * * * * * * ** ** ************ *
* ** *** * * * ** *** * * **** *** * **** **** * * * * ****** *** * * *** ** ***** **** * ** * * * ** day!");
* * ** * ********* ** * * * * * ** * *** ***** * * *** *** * * *
* *** * * ** ** ** * * * ** * * ** **** * * ***

}

}
answered by (-226 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main(void)

{
* ** * * **** ***** * m1, m2, d1, d2, y1, y2;
* ***** ** ** ** *** ** * * ***** * * *** *** &m1, &d1, &y1);
** * *** * * * * *** *** **** * * ** * &m2, &d2, &y2);


** * * ******* ** ** (y1<y2)
* * ** * * ** ** * ** * * * * **** *** *** *** ** is earlier than ** ** * d1, y1, m2, d2, y2);
*** * ** ** ******* * if (y1==y2)
* ** ***** * ** *** *
** **** ** * * * *** ***** ** * * * ** (m1<m2)
* *** ** * * * * *** *** * ** ** * *** ** * *** **** * * * * * * ***** is earlier than ** * * *** *** ** d1, y1, m2, d2, y2);
**** ** * ******* ** * * ******** * *** *** * if (m1==m2)
* * * * * **** ** * * * * *** ** * * * ******
**** ** *** *** * ** * * * *** ******* * *** ** * * **** * ** (d1<d2)
* * * **** ** * **** * * * ** * ** ** ****** * * * *** *** * * * **** ***** *** ** ** * ** ** is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
* * * **** * ** *** **** * * ****** * *** **** *** ***** * * ** ** **** * * if (d1>d2)
* * * ** * * *** **** * * ** *** * * * *** ** *** * * ** * * ** **** * * *** **** ** ** * *** * is earlier than * *** * ** * * d2, y2, m1, d1, y1);
* * ** ** *** * *** *** * ** ** ** * ** * * * * * * ** ***
* * ****** * ** * *** * ** ** * *** ** **** ** ** * **** * * ** * ** *** **** * * **** * * valid");
* ** * * ****** * *** ***** ** * * **** * ** *
* ** ** * * * **** ** * * ** ** * * * * * ***
** * ** * ** * * ** * * * * * ** * *** * ** * ** ** ***** ******* * ** ** *** * ** * * * is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);
* ** * * ** ** **
** * ** * * * ** * ** **
** * ** ****** * *** ******* * ** * * ** * * * * * * ** ****** ** * is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);


* *** ** *** ******** * 0;

}
answered by (38 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.127.67
©2016-2024

Related questions

0 like 0 dislike
50 answers
[Exercise] Coding (C) - asked Mar 16, 2017 in C
ID: 22973 - Available when: Unlimited - Due to: Unlimited
| 1.1k views
0 like 0 dislike
82 answers
[Exercise] Coding (C) - asked Mar 9, 2017 in C by thopd (12.1k points)
ID: 22674 - Available when: Unlimited - Due to: Unlimited
| 1.4k views
0 like 0 dislike
111 answers
asked Mar 16, 2017 in C by thopd (12.1k points) | 2.4k views
12,783 questions
183,443 answers
172,219 comments
4,824 users