请各位高手帮忙(100分)

  • 主题发起人 zhangsuzhou
  • 开始时间
Z

zhangsuzhou

Unregistered / Unconfirmed
GUEST, unregistred user!
编写一个C++程序,用面向流的输入/输出提示用户输入7个整数,
计算并打印出其中的最大值。
 
#include<isostream.h>
int temp,max,i,;
max=0;
for i=1 to 7do
{ cin>>temp;
if temp>max then
max=temp;
}
cout>>max
二年前我肯定准确无误的写出来,现在恐怕错误一大堆了,你自己调试调试吧

 
错远了..for语句不是这样用的.
include <iostream.h>
main(){
int temp,max,i,;
max=0;
for(i=1;i<=7;i++)
{ cin>>temp;
if (temp>max)
max=temp;
}
cout<<max;
}
 
哈哈,别的不说,楼上连基本的cout的语句都错了,
是cout<<,cin才是>>的,
 
靠,刚才没注意,
for(i=1;i<=7;i++)do
/////不要do
{ cin>>temp;
if (temp>max) then
//不要then
,哎,delphi都用惯了
max=temp;
}
cout>>max;
}
 
#include <iostream.h>
int temp,m;
m=0;
for(int i=1;i<=7;i++)
{
cin>>temp;
if(temp>m)
m=temp;
}
cout<<m<<endl;
 
看来大家用delphi用久了.
编出来的c程序都带着一股浓浓的pascal味道了
 
已经很不习惯用C++的语法了...
 
晕.都回去了...
 
include <iostream.h>
main(){
int temp[7],max,i,;
max=0;
for(i=1;i<=7;i++)
{ cin>>temp;
}
for(i=1;i<=7;i++)
{ if (temp>max)
max=temp;
}
cout<<max;
}
 

Similar threads

回复
0
查看
855
不得闲
D
回复
0
查看
738
DelphiTeacher的专栏
D
D
回复
0
查看
742
DelphiTeacher的专栏
D
顶部