【openjudge 计算概论(A)】[结构体与链表练习]
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct ch{
string name;
int yue,day,len;
}child[200];
int tmp(ch a,ch b)
{
if (a.yue<b.yue) return 1;
if (a.yue>b.yue) return 0;
if (a.day<b.day) return 1;
if (a.day>b.day) return 0;
if (a.len<b.len) return 1;
if (a.len>b.len) return 0;
if (a.name<b.name) return 1;
return 0;
}
int n;
int main()
{
int i;
bool t=0;
scanf("%d",&n);
for (int i=1;i<=n;i++)
{
cin>>child[i].name;
child[i].len=child[i].name.length();
scanf("%d%d",&child[i].yue,&child[i].day);
}
sort(child+1,child+n+1,tmp);
i=1;
while(i<=n)
{
if (child[i].yue==child[i+1].yue&&child[i].day==child[i+1].day)
{
t=1;
printf("%d %d ",child[i].yue,child[i].day);
cout<<child[i].name<<' ';
int a,b;
a=child[i].yue; b=child[i].day;
i++;
while(child[i].yue==a&&child[i].day==b)
cout<<child[i++].name<<' ';
printf("\n");
}
else ++i;
}
if (!t) printf("None\n");
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a[200010],x;
int main()
{
int i;
scanf("%d",&n);
for (i=1;i<=n;++i) scanf("%d",&a[i]);
scanf("%d",&x);
for (i=1;i<=n;++i)
if (a[i]!=x)
printf("%d ",a[i]);
return 0;
}
[不会链表!拒绝链表!]
3:统计学生信息(使用动态链表完成)
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char s[11100][210];
int top;
int main()
{
int i;
while(gets(s[++top]));
top-=2;
for (i=top;i>=1;i--)
printf("%s\n",s[i]);
return 0;
}
[这样良心的题为什么要搞链表。。。]
既然无能更改,又何必枉自寻烦忧