这是我明天考C++的答案,你们别看进来
州民中吧
全部回复
仅看楼主
level 12
zm你懂 楼主
一楼拜春哥,明天不挂科。
2013年01月02日 07点01分 1
level 12
zm你懂 楼主

试题一:
#include <iostream>
using namespace std;
int main()
{
int T,n,*p,i,j,k,t,s=0;
cin>>T;
while(T--)
{
s++;
cin>>n;
p=new int[n];
for(i=0;i<n;i++)
{
cin>>p[i];
}
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(p[k]>p[j])
k=j;
if(k!=i)
{
t=p[k];
p[k]=p[i];
p[i]=t;
}
}
cout<<"Case "<<s<<":"<<endl;
for(i=0;i<n-1;i++)
cout<<p[i]<<" ";
cout<<p[i]<<endl;
}
return 0;
}
2013年01月02日 07点01分 2
level 12
zm你懂 楼主

试题二:
#include <iostream>
using namespace std;
const int M=40;
int main()
{
int T,n,i,j,k;
char *p[M],t[M];
cin>>T;
while(T--)
{
cin>>n;
getchar();
for(i=0;i<n;i++)
{
p[i]=new char[M];
cin.getline(p[i],40);
}
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(strcmp(p[k],p[j])>0)
k=j;
strcpy(t,p[k]);
strcpy(p[k],p[i]);
strcpy(p[i],t);
}
for(i=0;i<n;i++)
cout<<p[i]<<endl;
}
return 0;
}
2013年01月02日 07点01分 3
level 12
zm你懂 楼主

试题3:
#include <iostream>
#include <iomanip>
using namespace std;
const int M=20;
struct book
{
char name[M];
float price;
char writer[M];
char publisher[M];
}
a[50],t;
int main()
{
int n,i,j,k;
while(cin>>n)
{
for(i=0;i<n;i++)
{
cin>>a[i].name>>a[i].price>>a[i].writer>>a[i].publisher;
}
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(strcmp(a[k].name,a[j].name)>0)
k=j;
if(k!=i)
{
t=a[k];
a[k]=a[i];
a[i]=t;
}
}
for(i=0;i<n;i++)
{
cout.setf(ios::left);
cout<<setw(20)<<a[i].name<<setw(20)<<a[i].price<<setw(20)<<a[i].writer<<setw(20)<<a[i].publisher;
}
cout<<endl;
}
return 0;
}
2013年01月02日 07点01分 4
level 12
zm你懂 楼主

试题4:
#include <iostream>
using namespace std;
const int M=50;
struct student
{
int number;
int nextp;
}link[M+1];
int main()
{
int i,h,n,T,count;
cin>>T;
while(T--)
{
cin>>n;
for(i=1;i<=n;i++)
{
if(i==n)
link[i].nextp=1;
else
link[i].nextp=i+1;
link[i].number=i;
}
count=0;
h=n;
cout<<"退出的小朋友是:"<<endl;
while(count<n-1)
{
i=0;
while(i!=3)
{
h=link[h].nextp;
if(link[h].number)
i++;
}
cout<<link[h].number<<" ";
link[h].number=0;
count++;
}
cout<<endl;
cout<<"最后剩下的是:";
for(i=1;i<=n;i++)
if(link[i].number)
cout<<link[i].number<<endl;
}
return 0;
}
2013年01月02日 07点01分 5
level 12
C++…好复杂的语言…
2013年01月02日 07点01分 6
C++已经算简单的了
2013年01月02日 07点01分
回复@zm你懂 :窝只会中文[委屈]
2013年01月02日 07点01分
回复 v342204067 :你学了就会觉得好简单的
2013年01月02日 07点01分
回复@zm你懂 :以后说不定会接触一点,C++貌似应用也挺广的
2013年01月02日 07点01分
level 8
不是说C语言是计算机最难的么?
2013年01月02日 07点01分 7
有吗?C不难啊
2013年01月02日 07点01分
@zm你懂 额。。。
2013年01月02日 07点01分
回复 丶戏耍 :C语言是面向对象的一种可视化程序语言,特别好哦,初学者学这个最好
2013年01月02日 08点01分
C确实说简单确实简单,考个国二轻轻松松。但是难的,还是得下点功夫的。
2013年01月03日 01点01分
level 13

表示只看得懂易语言。。
2013年01月02日 07点01分 8
什么语言??
2013年01月02日 07点01分
回复 zm你懂 :易语言啊
2013年01月02日 07点01分
回复 小猫SHARP :什么东西
2013年01月02日 08点01分
回复 zm你懂 : 易语言 就是 中文编程
2013年01月02日 10点01分
level 13
[汗]
这是毛= =
2013年01月02日 07点01分 9
C++啊
2013年01月02日 08点01分
level 12
这是毛 [真棒][汗][啊]
2013年01月02日 09点01分 11
c++、、、
2013年01月02日 10点01分
球解释,真心不懂
2013年01月02日 14点01分
回复 罪过狼狈丶 :解释了你也不懂
2013年01月02日 14点01分
[委屈][泪][笑眼] 好吧好吧
2013年01月03日 03点01分
level 13

竟然易语言都不知道[揉脸]
2013年01月02日 09点01分 12
真的不知道
2013年01月02日 10点01分
level 11
这是毛
2013年01月02日 10点01分 13
c语言啊
2013年01月02日 10点01分
level 11
孩纸 去学下JAVA 学学语法结构 和严谨的代码
对你以后编程有好处的
如果代码都是这么排版的 我是老师 直接零分
2013年01月02日 10点01分 14
我本来格式好好的,尼玛一提交就这样了。而且这代码太简单鸟……JAVA寒假自己学……
2013年01月02日 11点01分
梁总学的是什么
2013年01月02日 14点01分
回复 小猫SHARP :梁总什么都学
2013年01月02日 14点01分
level 13
这是毛呀?
2013年01月02日 10点01分 15
level 12
zm你懂 楼主
要去考试了,顶起来……
2013年01月03日 00点01分 16
level 8
不是三月份考么?[呼~]和VF一起
2013年01月03日 02点01分 17
我们只是期末上机考试而已
2013年01月03日 02点01分
回复 zm你懂 :好吧,昨天刚考完[笑眼]
2013年01月03日 02点01分
回复 遗忘_结晶 :你也学的计算机?
2013年01月03日 03点01分
回复 zm你懂 :通信工程,只是昨天晚上计算机期末考试
2013年01月03日 03点01分
level 14
求大神帮忙明年过二级c语言
2013年01月03日 03点01分 18
so easy!
2013年01月03日 03点01分
回复 zm你懂 :[惊讶]
2013年01月03日 03点01分
level 7
这是毛…
2013年01月03日 05点01分 19
level 12
zm你懂 楼主

只能说这些题目太简单了
太没有压力。。。。
知道我为什么发这贴吗?
因为我要骗经验!!!!哈哈
2013年01月03日 08点01分 20
1