⑴ 用Vc++编写程序,根据输入的年月,输出该月的天数,到底那里错了怎样改
变量使用前用先赋初值。
你的逻辑表达式有问题。
如果是大月,有赋值。如果是平月,有赋值。如果是小月,也有赋值。这是正确的。
问题出在最后两句,那个else 是永远也执行不到的。所以最后一句的d是得不到赋值的。
根据最近匹配原则,你的逻辑是,m既不是大月也不是小月也不是平月,才打印。。。(怎么可能有这样的月呢)
所以去掉最后一个else就好了。
⑵ 在vc6.0使用时间暂留不行
sleep(100)表示停留100毫秒,只有0.1秒钟,你感觉不出来的。
⑶ VC++6.0,怎样用语句来修改系统时间.
vc++6.0中可以使用setLocalTime函数来修改系统时间。
使用API函数SetLocalTime进行本地时间设置的方法:
1)SetLocalTime函数的原型:
BOOL SetLocalTime( const SYSTEMTIME *lpSystemTime );
输入参数lpSystemTime是一个SYSTEMTIME类型的参数,如果设置成功,返回true,本地时间将会变成lpSystemTime所指定的时间,否则返回false。
看一下SYSTEMTIME的格式:
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;
2)利用SYSTEMTIME结构体和SetLocalTime函数进行本地时间的设置举例:
SYSTEMTIME st;结构体声明
st.wYear = 2007;赋值年份
st.wMonth = 11;赋值月份
st.wDay = 24;赋值天
st.wHour = 3;赋值小时
st.wMinute = 14;赋值分钟
st.wSecond = 0;赋值秒
st.wMilliseconds = 0;赋值毫秒
SetSystemTime(&st);把结构体变量出入SetSystemTime函数即可。
以上对结构体成员的赋值,除wDayOfWeek成员之外,其它各成员都进行赋值了,甚至连wMilliseconds。使用这种方式进行系统时间设置时,会忽略wDayOfWeek成员,可以不进行该成员的赋值(即使你赋值了也不会被考虑的),但其它所有成员都必须时行赋值,否则无法成功地进行时间设置。
⑷ PE/VC 创投的期限是“8+1+1”年是啥意思啊 如果是8+1+1的话,营业执照上写几年啊
投资期限适合不同的基金相关的。 而一个创投可能可以管理好几支基金。 每只内基金都会有个容年限, 通常我看到的是8+2, 意思是基金投资到回报基本是8年, 但如果多数投资人同意的情况下,可以延期两年结算。 也有是3+5的说法,三年投资,五年回收投资
⑸ VC设置系统日期,是日期
看看有没有相关的API可以用
IContactProperties::SetDate Method
Sets the date and time value at a specified property to a given FILETIME. All times are stored and returned as coordinated universal time (UTC).
Syntax
HRESULT SetDate( LPCWSTR pszPropertyName,
DWORD dwFlags,
FILETIME ftDateTime
);
Parameters
pszPropertyName
[in] Specifies the property to set.
dwFlags
[in] CGD_DEFAULT can be used to create or overwrite value at pszPropertyName.
ftDateTime
[in] FILETIME structure to use for date.
Return Value
Returns one of the following values:
S_OK Value is set at this property.
ERROR_PATH_NOT_FOUND Property name invalid for set.
ERROR_INVALID_DATATYPE Unable to set the value for this property e to schema.
setTime Method
Sets the date and time value in the Date object.
dateObj.setTime(milliseconds)
Arguments
dateObj
Required. Any Date object.
milliseconds
Required. A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.
Remarks
If milliseconds is negative, it indicates a date before 1970. The range of available dates is approximately 285,616 years from either side of 1970.
Setting the date and time with the setTime method is independent of the time zone.
Example
The following example illustrates the use of the setTime method.
function SetTimeTest(newtime){
var d, s; //Declare variables.
d = new Date(); //Create Date object.
d.setTime(newtime); //Set time.
s = "Current setting is ";
s += d.toUTCString();
return(s); //Return new setting.
}
Requirements
Version 1
See Also
Date Object Methods | getTime Method
Applies To: Date Object
--------------------------------------------------------------------------------
Send feedback on this topic to Microsoft.
© Microsoft Corporation. All rights reserved.
⑹ VC++ 用类表示某一个日期
VC++ 用类表示某一个日期
#include<iostream.h>
class ctime
{
private:
int year; //年
int month; //月
int day; //日
public:
ctime(int y=2000,int m=1,int d=1): //构造函数1
year(y),month(m),day(y)
{}
ctime(ctime&c) //构造函数2
{
month=c.month;
day=c.day;
year=c.year;
}
~ctime(void)
{}
void printctime(void)const //输出
{
cout<<year<<"年"<<month<<"月"<<day<<"日"<<endl;
}
};
void main(void)
{
ctime today(2009,9,17);//使用构造函数1的对象定义
ctime someday;//使用默认值得对象定义
ctime someday2(today);//使用构造函数2的对象定义
someday.printctime();//打印默认日期
someday2.printctime();//打印当前日期
}
⑺ 用vc++编写一个日期类,并实现日期类型数据的初始化和输出
注释。
1. for i in `ls *.mp3`
2. cp $file $target
3. [ $foo = "bar" ]
4. cd `dirname "$f"`
5. [ "$foo" = bar && "$bar" = foo ]
6. [[ $foo > 7 ]]
7. grep foo bar | while read line; do ((count++) ); done
8. if [grep foo myfile]
9. if [bar="$foo"]
10. if [ [ a = b ] && [ c = d ] ]
11. cat file | sed s/foo/bar/ > file
12. echo $foo
13. $foo=bar
14. foo = bar
15. echo <<EOF
16. su -c 'some command'
17. cd /foo; bar
18. [ bar == "$foo" ]
19. for i in {1..10}; do ./something &; done
20. cmd1 && cmd2 || cmd3
21. UTF-8的BOM(Byte-Order Marks)问题
22. echo "Hello World!"
23. for arg in $*
24. function foo()
⑻ 用C++编程一个日期
你先看看这个功能的datatype类,符不符合你要求。
下面我贴出这个类的源码:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
usingnamespacestd;
classDateType{
inty,m,d;
public:
DateType(intyi=1,intmi=1,intdi=1);
voidreset_date();//重设日期
voidadd_oneday();//增加一天
intre_weekday();//返回0-6,以1年1月1日为星期一
intre_days(intmonth);//返回指定月的天数
doubled_day_111();//与1年1月1日相差的天数
doubled_day(DateTypedate);//与Date相差的天数
voidprint_table();//打印当月月历
voidprint_table_this(intmonth);//打印指定月历
boolthe_same(DateTypedate);//与Date是否是同一日期
voidprint_date();//打印当前日期
voidprint_animal();//打印当前日期的生肖年
voidprint_star();//打印当前日期星座
voidprint_week();//打印当前日期的星期
};
DateType::DateType(intyi,intmi,intdi){
y=yi;
m=mi;
d=di;
}
voidDateType::reset_date(){
intrun,dx;
cout<<"年:";
cin>>y;
while(y<1){
cout<<"请重新输入年份! ";
cout<<"年:";
cin>>y;
}
cout<<"月:";
cin>>m;
while(m<1||m>12){
cout<<"请重新输入月份! ";
cout<<"月:";
cin>>m;
}
cout<<"日:";
cin>>d;
if(m==2){
if(y%4==0&&y%100!=0||y%400==0)
run=29;
elserun=28;
while(d<1||d>run){
cout<<"请重新输入日期! ";
cout<<"日:";
cin>>d;
}
}
else{
if(m%2==1&&m<8||m%2==0&&m>7)
dx=31;
elsedx=30;
while(d<1||d>dx){
cout<<"请重新输入日期! ";
cout<<"日:";
cin>>d;
}
}
}
intDateType::re_weekday(){
intdy,dm,dd,py,Feb,dday=0,week,sum=0;
if(y==1){
if(m==1)
dday=d-1;
else{
for(intmon=1;mon<m;mon++)
dday=dday+re_days(mon)+d-1;
}
}
else{
dy=y-1;
dm=m-1;
dd=d-1;
for(inti=1;i<y;i++){
if(i%4==0&&i%100!=0||i%400==0){
py=366;
Feb=29;
}
else{
py=365;
Feb=28;
}
sum=(sum+py)%7;
}
if(m==2){
dday=sum+Feb+dd;
}
else{
if(dm>0&&dm<8){
dday=sum+((dm-1)/2+1)*31+(dm/2-1)*30+dd+Feb;
}
elseif(dm>7&&dm<12){
dday=sum+((dm-6)/2)*31+((dm-7)/2)*30+dd+Feb+184;
}
elseif(dm==0)
dday=sum+dd;
}
}
week=dday%7;//week=0,1,2,3,4,5,6星期一到星期日
returnweek;
}
intDateType::re_days(intmonth){
intday;
if(month==2){//二月
if(y%4==0&&y%100!=0||y%400==0)//闰年
day=29;
else//平常年
day=28;
}
else{//平常月
if((month%2==1&&month<8)||(month%2==0&&month>=8))//大月
day=31;
else//小月
day=30;
}
returnday;
}
voidDateType::add_oneday(){
intday=re_days(m);
if(d+1>day){
if(m+1>12){
y++;
m=1;
d=1;
}
else{
m++;
d=1;
}
}
elsed++;
}
boolDateType::the_same(DateTypedate){
if(y==date.y){
if(m==date.m){
if(d==date.d){
returntrue;
}
}
}
returnfalse;
}
voidDateType::print_date(){
cout<<"【"<<y<<"】年【"<<m<<"】月【"<<d<<"】日";
print_week();
cout<<"";
print_animal();
}
voidDateType::print_week(){
stringweeks[7]={"一","二","三","四","五","六","日"};
cout<<"【星期"<<weeks[re_weekday()]<<"】";
}
voidDateType::print_animal(){
stringanimal[12]={"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"};
intd_year=(y%12+8)%12;
cout<<"【"<<animal[d_year]<<"年】";
}
voidDateType::print_star(){
stringstar[12]={"魔羯座","水瓶座","双鱼座","牧羊座","金牛座","双子座","巨蟹座","狮子座","处女座","天秤座","天蝎座","射手座"};
}
doubleDateType::d_day_111(){
doubledday,sum=0.0;
intdy,dm,dd,Feb,py;
dy=y-1;
dm=m-1;
dd=d-1;
for(inti=2;i<=y;i++){
if(i%4==0&&i%100!=0||i%400==0){
py=366;
Feb=29;
}
else{
py=365;
Feb=28;
}
sum=sum+py;
}
if(m==2){
dday=sum+Feb+dd;
}
else{
if(dm>0&&dm<8){
dday=sum+((dm-1)/2+1)*31+(dm/2-1)*30+dd+Feb;
}
elseif(dm>7&&dm<12){
dday=sum+((dm-6)/2)*31+((dm-7)/2)*30+dd+Feb+184;
}
elseif(dm==0)
dday=sum+dd;
}
returndday;
}
doubleDateType::d_day(DateTypedate){
doubled1,d2,sum=0.0;
d1=d_day_111();
d2=date.d_day_111();
sum=fabs(d1-d2);
returnsum;
}
voidDateType::print_table(){
stringweeks[7]={"一","二","三","四","五","六","日"};
intweek1,monthday;
if(m==2){
if(y%4==0&&y%100!=0||y%400==0)
monthday=29;
else
monthday=28;
}
else{
if((m%2==1&&m<8)||(m%2==0&&m>=8))
monthday=31;
else
monthday=30;
}
DateTypeymd1(y,m,1);//当月一号
week1=ymd1.re_weekday();
intday=1,k=0;
for(inti=0;i<7;i++){
cout<<setw(5)<<weeks[i];
}
cout<<endl;
while(1){
if(k!=week1&&day==1){
k++;
cout<<setw(5)<<"";
}
else{
cout<<setw(5)<<day;
day++;
k++;
}
if((k)%7==0)
cout<<endl;
if(day>monthday)
break;
}
cout<<endl;
}
voidDateType::print_table_this(intmonth){
stringweeks[7]={"一","二","三","四","五","六","日"};
intweek1,monthday;
if(month==2){
if(y%4==0&&y%100!=0||y%400==0)
monthday=29;
else
monthday=28;
}
else{
if((month%2==1&&month<8)||(month%2==0&&month>=8))
monthday=31;
else
monthday=30;
}
DateTypeymd1(y,month,1);//当月一号
week1=ymd1.re_weekday();
intday=1,k=0;
for(inti=0;i<7;i++){
cout<<setw(5)<<weeks[i];
}
cout<<endl;
while(1){
if(k!=week1&&day==1){
k++;
cout<<setw(5)<<"";
}
else{
cout<<setw(5)<<day;
day++;
k++;
}
if((k)%7==0)
cout<<endl;
if(day>monthday)
break;
}
}
下面是主函数,是用来调试效果的:
#include<iostream>
#include"DateType.h"
usingnamespacestd;
DateTypedate1;
intchiose,month_input;
voidprint_table_ohter(){//查看指定月月历
while(1){
cout<<" 请输入要查看的月份:";
cin>>month_input;
if(month_input<1||month_input>12)
cout<<"月份错误,请重新输入! ";
else{
date1.print_table_this(month_input);
cout<<endl;
break;
}
}
}
voidget_d_days(){//计算两日期相差的天数
DateTypedate2;
DateTypedate3;
while(1){
cout<<"请输入日期一:";
date2.reset_date();
cout<<endl;
cout<<"请输入日期二:";
date3.reset_date();
cout<<endl;
date2.print_date();
cout<<"与";
date3.print_date();
cout<<"相差";
cout<<date2.d_day(date3)<<"天 ";
break;
}
}
voidmain(){
while(1){
cout<<setiosflags(ios::left);
cout<<setw(20)<<"1.跳至指定日期";
cout<<setw(15)<<"2.查看日期";
cout<<setw(25)<<"3.查看当月月历";
cout<<setw(20)<<"4.查看指定月月历";
cout<<setw(20)<<"5.增加一天";
cout<<setw(40)<<"6.计算两日期相差的天数";
cout<<setw(20)<<"7.待定";
cin>>chiose;
switch(chiose){
case1:date1.reset_date();break;
case2:date1.print_date();cout<<endl;break;
case3:date1.print_table();break;
case4:print_table_ohter();break;
case5:date1.add_oneday();date1.print_date();break;
case6:get_d_days();cout<<endl;break;
case7:break;
default:cout<<"您没有选择任何操作! ";break;
}
cout<<endl;
}
}
这是我做课程设计一时,做的题目,有点多,慢慢看,希望可以帮到你啦~
⑼ C语言编写 输入 年 月 日 ,输出这个日期的下一天的日期
利用C标准函数time,localtime,mktime来实现
先将输入的年月日放到tm结构中
用mktime()函数生成一个整数
用这个整数+86400(24*60*60)
然后再转换成日期就OK了
⑽ vc编程中日期加天数怎么算
使用CTimeSpan这个类,可以直接累加小时、天数 然后得到目标日期,很方便。