打印

[提问] 一道C语言基础题

我汗 真的5行 NB  不过好像不太现实  我们根本就没有学过sum() 还是给你加钱吧~
if (a != a) {
System.out.println("你太有才了");
}

TOP

回复 #29 water168 的帖子

定义一个  int sum[12];  那么sum[12]是不能使用的
很明显,你的这个程序还有点问题,还需要一些改动

TOP

拜托自己测试下

楼上的不要纸上谈兵呀..你测试了吗?自己学好了吗

TOP

楼上的说的简单哦
if (a != a) {
System.out.println("你太有才了");
}

TOP

都好强啊,把代码简化的不能再简化了,看来以后我写程序也得学着简化了。收藏这个帖子了。
研究VB和C++技术,X杂志忠实读者

TOP

回复 33# 的帖子

大哥 自己看清楚了再发言
支持 water168
写是写出来了,不过没有编程风格,不值得提倡

TOP

用C++也来写一下,main里一个分号算一行。
复制内容到剪贴板
代码:
#include<iostream>   //头文件不算
using namespace std;          //头文件不算
void main()
{
int i,all=0,year,month,day,str[12]={31,28,31,30,31,30,31,31,30,31,30,31};

cin>>year>>month>>day;

for(i=0;i<month-1;i++)  all=all+str;

if((year%4==0&year%100!=0)||(year%400==0))  cout<<all+day;

else  cout<<all+day+1;
}
[ 本帖最后由 BhackedBoy 于 2008-7-21 20:13 编辑 ]
C++,VB,黑客X档案忠实读者。

TOP

咳~~我只会delphi
复制内容到剪贴板
代码:
procedure TForm1.Button1Click(Sender: TObject);
const table:array[1..12] of Integer = (31,28,31,30,31,30,31,31,30,31,30,31) ;
var y,m,d:Integer;
      I:Integer;
      s:Integer;
begin
  s:=0;                             //这几行应该不算吧..
  y:=StrToInt(edtY.Text);
  m:=StrToInt(edtM.text);
  d:=StrToInt(edtD.Text); //*****************
  for I:=1 to m-1 do s:=s+table;
  if m>2 then begin
    if (y mod 400 = 0) or ((y mod 4 = 0) and (y mod 100 <> 0)) //闰年 3
      then s:=s+d+1;end
    else s:=s+d;
  edtOut.Text:=IntToStr(s);
end;
[ 本帖最后由 shn7798 于 2008-7-20 12:31 编辑 ]

TOP

....    看不懂,,

TOP

#include"stdio.h"
main()
{
int y,m,d;
int sz[13]={31,28,31,30,31,30,31,31,30,31,30,31};
int all ,i ;
all=0;
printf("eg:\n");
printf("2008,5,21\n");
printf("------------------\n");
printf("please input y month day:\n");
scanf("%d,%d,%d",&y,&m,&d);
if(y%4==0&&y%100!=0||y%400==0)
     {
      sz[1]=29;
      for(i=1;i<=m-1;i++)
      all=all+sz;
     }
else
     {
        for(i=1;i<=m-1;i++)
        all=all+sz;
     }
printf("%d天\n",all+d);
}


在C-FREE里调试成功:
没做错误处理;就对问题做了解答;
2月和润年的问题也解决了:

TOP

Processed in 0.272495 second(s), 5 queries, Gzip enabled.