简单的C语言小问题,拜托牛人解答

来源:百度知道 编辑:UC知道 时间:2024/05/24 09:58:19
Write a program to accept an integer from the user, and then print the integer in reverse order.
The reversed print should also be a proper integer. For example, if the input is 453600, then the
program outputs 6354; if the input is -9867, then the output is -7689; if the input is 9030; then
the output is 309; if the input is 0, then the output is 0. You are required to use a recursive
function when write the program.
第二题
As explained in the class, the function call time(NULL) returns the number of seconds elapsed
since the beginning of the day January, 1st, 1970. Write a program to calculate and display
current year, month and day according to this number.
我用的是VC++
请运行好了后再给我
实在是感激不尽啦
写的弱智一点就好,不要写得很深奥,否则太假了

第一题
#include<stdio.h>
#include<iostream>
using namespace std;
void main()
{
char a[20];
int len;
int sign=0;
cin>>a;
len=strlen(a);
for(int i=0; i<len/2; i++)
{
char temp;
temp=a[i];
a[i]=a[len-i-1];
a[len-i-1]=temp;
}
while(a[0]=='0')
{
sign++;
int i;
for(i=0; i<len-sign; i++)
a[i]=a[i+1];
a[i]='\0';
}
cout<<a<<endl;
system("pause");
}
第二题
#include <time.h>
#include "stdio.h"
#include "stdlib.h"
int main(void)
{
struct tm t;
time_t t_of_day;
t.tm_year=1997-1900;
t.tm_mon=6;
t.tm_mday=1;
t.tm_hour=0;
t.tm_min=0;
t.tm_sec=1;
t.tm_isdst=0;
t_of_day=mktime(&t);
printf(ctime(&t_of_day));
system("pause");
r