<!doctype html>

NEUQ-ACM-CAMP-B011-结构体-枚举

NEUQ-ACM-CAMP-B011-结构体-枚举
开始时间 2022/08/18 08:07:00
结束时间 2022/08/31 23:59:00
答题时长 19672分钟
答卷类型 标准答案
总分 100

程序填空题 得分:暂无 总分:10
5-1

下列程序读入时间数值,将其加1秒后输出,时间格式为:hh: mm: ss,即“小时:分钟:秒”,当小时等于24小时,置为0。

#include <stdio.h>
struct { int hour, minute, second;
} time;
int main(void)
{  scanf("%d:%d:%d", (1分) );time.second++;if( (1分) == 60){(1分) ; time.second = 0;if(time.minute == 60){time.hour++; time.minute = 0;if( (1分)  ) time.hour = 0; }}printf ("%d:%d:%d\n", time.hour, time.minute, time.second );
  return 0;

}


5-2

读入一个整型数表示的秒数,将它转换为时分秒格式并输出。

#include <stdio.h>
struct TIME {int sec, min, hour;
} time;

int main()
{
int t;

scanf(&quot;%d&quot;, &amp;t);
time.hour = <span data-reactroot=""><input type="text" style="max-width:none;width:19.2ch;max-height:500px" value="t / 3600" disabled=""/><span style="margin-left:4px;color:gray">(2分)</span></span>;
time.min = <span data-reactroot=""><input type="text" style="max-width:none;width:32.4ch;max-height:500px" value="(t - time.hour * 3600) / 60" disabled=""/><span style="margin-left:4px;color:gray">(2分)</span></span>;
time.sec = t % 60;printf (&quot;<span data-reactroot=""><input type="text" style="max-width:none;width:19.2ch;max-height:500px" value="%02d:%02d:%02d" disabled=""/><span style="margin-left:4px;color:gray">(2分)</span></span>\n&quot;, time.hour, time.min, time.sec);
return 0;

}

输入样例

4508

输出样例

01:15:08

函数题 得分:15 总分:15
6-1
计算两个复数之积
(10分)

本题要求实现一个计算复数之积的简单函数。

函数接口定义:

struct complex multiply(struct complex x, struct complex y);

其中struct complex是复数结构体,其定义如下:

struct complex{int real;int imag;
};

裁判测试程序样例:

#include <stdio.h>

struct complex{
int real;
int imag;
};

struct complex multiply(struct complex x, struct complex y);

int main()
{
struct complex product, x, y;

scanf(&quot;%d%d%d%d&quot;, &amp;x.real, &amp;x.imag, &amp;y.real, &amp;y.imag);
product = multiply(x, y);
printf(&quot;(%d+%di) * (%d+%di) = %d + %di\n&quot;, x.real, x.imag, y.real, y.imag, product.real, product.imag);return 0;

}

/* 你的代码将被嵌在这里 */

输入样例:

3 4 5 6

输出样例:

(3+4i) * (5+6i) = -9 + 38i
编译器
GCC
代码
struct complex multiply(struct complex x, struct complex y)
{int real, imag;real = x.real*y.real - x.imag*y.imag;imag = x.imag*y.real + x.real*y.imag;struct complex ret={real,imag};return ret;
};

评测结果
答案正确 (10 分)
编译器输出
a.c: In function ‘main’:
a.c:14:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]scanf("%d%d%d%d", &x.real, &x.imag, &y.real, &y.imag);^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

测试点得分
测试点 结果 得分 耗时 内存
0 答案正确 5 2.00 ms 188 KB
1 答案正确 3 2.00 ms 372 KB
2 答案正确 2 2.00 ms 196 KB

6-2
空间两点间的距离
(5分)

已知空间中两点 A(x1,y1,z1)A(x_1,y_1, z_1)A(x1​,y1​,z1​) 和 B(x2,y2,z2)B(x_2,y_2, z_2)B(x2​,y2​,z2​) 之间的欧氏距离定义为:(x1−x2)2+(y1−y2)2+(z1−z2)2\sqrt{(x_1-x_2)^2+(y_1-y_2)^2+(z_1-z_2)^2}(x1​−x2​)2+(y1​−y2​)2+(z1​−z2​)2 ​。

本题要求实现一个函数,计算平面上两点之间的欧氏距离,平面上点的坐标通过以下结构给出:

struct point {double x, y, z;
};

函数接口定义:

//  计算并返回平面上两点 a 和 b 之间的欧氏距离
double distance(struct point a, struct point b);

裁判测试程序样例:

#include <stdio.h>
#include <math.h>

struct point {
double x, y, z;
};

void read_point(struct point *p);
double distance(struct point a, struct point b);

int main(void)
{
struct point p1, p2;

read_point(&amp;p1);
read_point(&amp;p2);printf(&quot;%f\n&quot;, distance(p1, p2));return 0;

}

void read_point(struct point *p)
{
scanf("%lf %lf %lf", &p->x, &p->y, &p->z);
}

/* 请在这里填写答案 */

输入样例:

在这里给出一组输入。例如:

0 0 0 3 0 4

输出样例:

在这里给出相应的输出。例如:

5.000000
编译器
GCC
代码
//  计算并返回平面上两点 a 和 b 之间的欧氏距离
double distance(struct point a, struct point b)
{double dis;dis = sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2));return dis;
}

评测结果
答案正确 (5 分)
编译器输出
a.c: In function ‘read_point’:
a.c:25:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]scanf("%lf %lf %lf", &p->x, &p->y, &p->z);^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

测试点得分
测试点 结果 得分 耗时 内存
sample1 答案正确 3 2.00 ms 188 KB
sample2 答案正确 2 2.00 ms 328 KB

编程题 得分:75 总分:75
7-1
复数运算
(5分)

复数是由两个实数分别作为实部和虚部构成的一个复合数,从另一个角度来说复数就是由两个实数构成的有序对,在C语言中适合用结构类型来表示复数。现在要求用结构类型

typedef struct
{float x;float y;
} Comp;

及其变量来表示与存储复数,编写程序实现复数的加减法运算。

输入格式:

在一行输入四个用空格分开的实数a1 b1 a2 b2分别表示复数c1 = a1 + b1ic2 = a2 + b2i

输出格式:

复数的输出应符合数学上关于复数的表示习惯:实部与虚部都为零时只输出一个0.00; 有一个为零时,只输出非零的部分; 虚部为负时,例如3-4i,应输出为3.00-4.00i的形式,不要输出为3.00+-4.00i。实部与虚部均保留2位小数,例如3.00-4.00i
输出在两行进行,第一行输出求和的结果,第二行输出求差的结果。

输入样例:

5.00 4.00 3.00 2.00

输出样例:

8.00+6.00i
2.00+2.00i

编译器
GCC

代码
#include<stdio.h>
#include<math.h>
typedef struct
{float x;float y;
} Comp;

Comp add(Comp x, Comp y);
Comp sub(Comp x, Comp y);
Comp multiply(Comp x, Comp y);
void print(Comp x);

int main()
{
float a1,b1,a2,b2;
scanf("%f%f%f%f",&a1,&b1,&a2,&b2);

Comp x,y;
x.x=a1, x.y=b1;
y.x=a2, y.y=b2;Comp a = add(x,y);
Comp b = sub(x,y);print(a);
printf(&quot;\n&quot;);
print(b);return 0;

}

Comp multiply(Comp x, Comp y)
{
float real, imag;
real = x.xy.x - x.yy.y;
imag = x.yy.x + x.xy.y;
Comp ret={real,imag};
return ret;
};

Comp add(Comp x, Comp y)
{
float real, imag;
real = x.x+y.x;
imag = x.y+y.y;
Comp ret;
ret.x=real,ret.y = imag;
return ret;
};

Comp sub(Comp x, Comp y)
{
float real, imag;
real = x.x-y.x;
imag = x.y-y.y;
Comp ret;
ret.x=real,ret.y = imag;
return ret;
};

void print(Comp x)
{
if (x.x0 && x.y0)
printf(“0.00”);
else if(x.y==0)
printf(“%.2f”,x.x);
else if(x.x == 0)
printf(“%.2fi”,x.y);
else if(x.y>0)
printf(“%.2f+%.2fi”,x.x,x.y);
else
printf(“%.2f%.2fi”,x.x,x.y);
}

评测结果
答案正确 (5 分)
编译器输出
a.c: In function ‘main’:
a.c:19:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf(“%f%f%f%f”,&a1,&b1,&a2,&b2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

测试点得分
测试点 结果 得分 耗时 内存
1 答案正确 2 2.00 ms 320 KB
2 答案正确 1 2.00 ms 188 KB
3 答案正确 1 2.00 ms 184 KB
4 答案正确 1 2.00 ms 188 KB

7-2
结构体应用:计算总分及最高分
(10分)

本题目要求先输入正整数N,然后输入N个类型为结构体stud的数组元素,计算每个学生的总分,输出每个学生的学号、姓名、三门课的成绩及总分;计算全部成绩的平均分并输出;输出总分最高同学的各项信息。
struct stud {
int num; //学号
char name[10]; //姓名
int score[3]; //3门课成绩
int sum; //总分
};

输入格式:

先输入不超过10的一个正整数N,然后每行输入一个学生的信息(学号、姓名、三门课成绩)。学号在整数范围内,姓名长度小于10个字符。

输出格式:

首先输出每个学生的信息(包括学号、姓名、三门课成绩、总分),数据项之间空1格,每人一行;再输出全部成绩的平均分;最后输出总分最高(假设没有相同总分)同学的学号、姓名、三门课成绩及总分,数据项之间空1格。

输入样例:

在这里给出一组输入。例如:

4
1  张三  81  85  82
2  李四  82  78  74
3  王五  85  74  90
4  赵六  77  85  79

输出样例:

在这里给出相应的输出。例如:

1 张三 81 85 82 248
2 李四 82 78 74 234
3 王五 85 74 90 249
4 赵六 77 85 79 241
总平均分=81.000000
3 王五 85 74 90 249
编译器
GXX
代码
#include <bits/stdc++.h>
using namespace std;
struct stud
{int num; //学号char name[10]; //姓名int score[3]; //3门课成绩int sum; //总分
};

int main()
{
int n;
cin>>n;

stud st[n];
int max=-1, pos=-1,sum=0;
for(int i=0;i&lt;n; i++)
{cin&gt;&gt;st[i].num;cin&gt;&gt;st[i].name;cin&gt;&gt;st[i].score[0]&gt;&gt;st[i].score[1]&gt;&gt;st[i].score[2];st[i].sum=st[i].score[0]+st[i].score[1]+st[i].score[2];if (max &lt; st[i].sum){max = st[i].sum;pos = i;}sum += st[i].sum;
}for(int i=0;i&lt;n; i++){cout&lt;&lt;st[i].num&lt;&lt;' '&lt;&lt;st[i].name&lt;&lt;' '&lt;&lt;st[i].score[0]&lt;&lt;' '&lt;&lt;st[i].score[1]&lt;&lt;' '&lt;&lt;st[i].score[2]&lt;&lt;' '&lt;&lt;st[i].sum&lt;&lt;endl;}
double avg = (double)sum / (n*3.0);
cout&lt;&lt;&quot;总平均分=&quot;;
printf(&quot;%.6f\n&quot;,avg);int i=pos;
cout&lt;&lt;st[i].num&lt;&lt;' '&lt;&lt;st[i].name&lt;&lt;' '&lt;&lt;st[i].score[0]&lt;&lt;' '&lt;&lt;st[i].score[1]&lt;&lt;' '&lt;&lt;st[i].score[2]&lt;&lt;' '&lt;&lt;st[i].sum&lt;&lt;endl;return 0;

}

评测结果
答案正确 (10 分)
测试点得分
测试点 结果 得分 耗时 内存
0 答案正确 5 3.00 ms 448 KB
1 答案正确 3 3.00 ms 444 KB
2 答案正确 2 3.00 ms 448 KB

7-3
2021-结构体-circle
(5分)

定义一个结构体类型表示一个圆(x,y,r),圆心坐标是(x,y),圆半径是r。从键盘输入一个圆的圆心坐标和半径,坐标值和半径均为整型数据,输出这个圆的面积,面积为float。面积公式为area=3.14∗r∗rarea =3.14rrarea=3.14∗r∗r.

输入格式:

从键盘输入圆的圆心坐标和半径,之间用空格分隔

输出格式:

输出数据保留两位小数。

输入样例:

在这里给出一组输入。例如:

3 4 5

输出样例:

在这里给出相应的输出。例如:

78.50
编译器
GXX
代码
#include <bits/stdc++.h>
using namespace std;
struct Circle
{int x,y,r;float GetArea(){return (float) 3.14 * r * r;}
};

int main()
{
Circle c1;
cin>>c1.x>>c1.y>>c1.r;

cout&lt;&lt;fixed&lt;&lt;setprecision(2)&lt;&lt; c1.GetArea();return 0;

}

评测结果
答案正确 (5 分)
测试点得分
测试点 结果 得分 耗时 内存
1 答案正确 5 3.00 ms 444 KB

7-4
寻找最高分
(5分)

  给定n(n⩾1)n(n\geqslant1)n(n⩾1)个学生的学号、姓名和3门课的考试成绩。编写程序找出总分最高的学生,并输出其学号、姓名和总分。如果有多个相同的最高分,则输出所有最高分学生的信息。
要求:
  存储学生信息及考试成绩的变量用如下结构类型来定义。

struct  Student
{char num[11];        //学号,最多10个字符char name[11];       //姓名, 最多10个字符int s1,s2,s3;        //三门课的考试成绩 int total;           //总成绩
} ;
typedef struct Student Student;  //声明了一个结构类型Student类型

输入格式:

输入在一行中给出非负整数n(n⩾1)n(n\geqslant1)n(n⩾1)。随后nnn行,每行给出一个学生的信息,格式为学号 学号 姓名 成绩1 成绩2 成绩3,中间以空格分隔。
要求:
学号姓名中不包括空白字符(空格、tab符)和空字符串。

输出格式:

在一行中输出总分最高学生的姓名、学号和总分,间隔一个空格。题目保证这样的学生是唯一的。

输入样例:

5
2109001 HuangJie 78 83 79
2109002 Liuhaipeng 79 80 77
2109003 Wangqiang 87 86 76
2109004 Liangfeng 92 89 79
2109005 Chengmeng 80 82 75

输出样例:

在这里给出相应的输出。例如:

2109004 Liangfeng 260
编译器
GXX
代码
#include <bits/stdc++.h>
using namespace std;

struct Student
{
string num; //学号,最多10个字符
string name; //姓名, 最多10个字符
int s1,s2,s3; //三门课的考试成绩
int total; //总成绩
bool operator < (const Student &s) const
{
return total < s.total;
}
} ;

int main()
{
int n;
cin>>n;

priority_queue&lt;Student&gt; Q;
for(int i=0; i&lt;n; i++)
{Student st;cin&gt;&gt;st.num&gt;&gt;st.name&gt;&gt;st.s1&gt;&gt;st.s2&gt;&gt;st.s3;st.total = st.s1+st.s2+st.s3;Q.push(st);
}Student st;
int flag;
st = Q.top();
Q.pop();
flag = st.total;
cout&lt;&lt;st.num&lt;&lt;' '&lt;&lt;st.name&lt;&lt;' '&lt;&lt;st.total&lt;&lt;'\n';while (!Q.empty())
{st = Q.top();Q.pop();if (st.total == flag)cout&lt;&lt;st.num&lt;&lt;' '&lt;&lt;st.name&lt;&lt;' '&lt;&lt;st.total&lt;&lt;endl;else break;
}return 0;

}

评测结果
答案正确 (5 分)
测试点得分
测试点 结果 得分 耗时 内存
0 答案正确 3 3.00 ms 324 KB
1 答案正确 1 3.00 ms 324 KB
2 答案正确 1 3.00 ms 320 KB

7-5
平面向量加法
(10分)

本题要求编写程序,计算两个二维平面向量的和向量。

输入格式:

输入在一行中按照“x1x_1x1​ y1y_1y1​ x2x_2x2​ y2y_2y2​”的格式给出两个二维平面向量v1=(x1,y1)v_1=(x_1, y_1)v1​=(x1​,y1​)和v2=(x2,y2)v_2=(x_2, y_2)v2​=(x2​,y2​)的分量。

输出格式:

在一行中按照(x, y)的格式输出和向量,坐标输出小数点后一位(注意不能输出−0.0-0.0−0.0)。

输入样例:

3.5 -2.7 -13.9 8.7

输出样例:

(-10.4, 6.0)
编译器
GXX
代码
#include<bits/stdc++.h>
using namespace std;

struct V
{
double x,y;
};

int main()
{
V v1,v2,v;
cin>>v1.x>>v1.y;
cin>>v2.x>>v2.y;
v.x = v1.x + v2.x;
v.y = v1.y + v2.y;

if(fabs(v.y)&lt;0.05) v.y=0;
if(fabs(v.x)&lt;0.05) v.x=0;
printf(&quot;(%.1lf, %.1lf)\n&quot;,v.x,v.y);return 0;

}

评测结果
答案正确 (10 分)
测试点得分
测试点 结果 得分 耗时 内存
0 答案正确 5 3.00 ms 452 KB
1 答案正确 5 3.00 ms 452 KB

7-6
有理数比较
(10分)

本题要求编写程序,比较两个有理数的大小。

输入格式:

输入在一行中按照“a1/b1 a2/b2”的格式给出两个分数形式的有理数,其中分子和分母全是整形范围内的正整数。

输出格式:

在一行中按照“a1/b1 关系符 a2/b2”的格式输出两个有理数的关系。其中“>>>”表示“大于”,“<<<”表示“小于”,“===”表示“等于”。

输入样例1:

1/2 3/4

输出样例1:

1/2 < 3/4

输入样例2:

6/8 3/4

输出样例2:

6/8 = 3/4
编译器
GXX
代码
#include <bits/stdc++.h>
using namespace std;
struct fraction
{int sign;int fz;int fm;
};

fraction add(const fraction &a, const fraction &b)
{
fraction ans;
if (a.sign == b.sign)
{
ans.sign = a.sign;
ans.fz = a.fzb.fm+a.fmb.fz;
ans.fm = a.fm * b.fm;
}
else
{
ans.fz = a.sign * a.fzb.fm + a.fmb.signb.fz;
ans.fm = a.fm
b.fm;
if (ans.fz <0) ans.sign = -1;
else ans.sign = 1;
}
int gcd = __gcd(ans.fz,ans.fm);
ans.fz = ans.fz / gcd;
ans.fm = ans.fm / gcd;

return ans;

}

fraction sub(const fraction &a, const fraction &b)
{
fraction c = b;
c.sign = -c.sign;
return add(a,c);
}

void print(const fraction &f)
{
if (f.fm == 1) cout<<f.signf.fz;
else
cout<<f.sign
f.fz<<'/'<<f.fm;
}

fraction read()
{
int z,m;
char slash;
fraction temp= {1,0,1};

cin&gt;&gt;z&gt;&gt;slash&gt;&gt;m;
temp.sign = (z&gt;=0)?1:-1;
temp.fz = temp.sign *z;
temp.fm = m;return temp;

}

char fraction_compare(fraction &a,fraction &b)
{
fraction res = sub(a,b);

if (res.sign ==1 &amp;&amp; res.fz&gt;0)return '&gt;';
else if(res.fz == 0)return '=';
else return '&lt;';

}

int main()
{
fraction a=read();
fraction b=read();
fraction res = sub(a,b);
print(a);
cout<<’ ‘<<fraction_compare(a,b)<<’ ';
print(b);
return 0;
}

评测结果
答案正确 (10 分)
编译器输出
a.cpp: In function ‘int main()’:
a.cpp:76:14: warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
fraction res = sub(a,b);
^~~

测试点得分
测试点 结果 得分 耗时 内存
0 答案正确 3 3.00 ms 324 KB
1 答案正确 3 3.00 ms 324 KB
2 答案正确 2 3.00 ms 308 KB
3 答案正确 2 3.00 ms 448 KB

7-7
有理数加法
(10分)

本题要求编写程序,计算两个有理数的和。

输入格式:

输入在一行中按照a1/b1 a2/b2的格式给出两个分数形式的有理数,其中分子和分母全是整形范围内的正整数。

输出格式:

在一行中按照a/b的格式输出两个有理数的和。注意必须是该有理数的最简分数形式,若分母为1,则只输出分子。

输入样例1:

1/3 1/6

输出样例1:

1/2

输入样例2:

4/3 2/3

输出样例2:

2
编译器
GXX
代码
#include <bits/stdc++.h>
using namespace std;
struct fraction
{int sign;int fz;int fm;
};

fraction add(const fraction &a, const fraction &b)
{
fraction ans;
if (a.sign == b.sign)
{
ans.sign = a.sign;
ans.fz = a.fzb.fm+a.fmb.fz;
ans.fm = a.fm * b.fm;
}
else
{
ans.fz = a.sign * a.fzb.fm + a.fmb.signb.fz;
ans.fm = a.fm
b.fm;
(ans.fz <0)? (ans.sign = -1,ans.fz=-ans.fz):(ans.sign=1);

}
int gcd = __gcd(ans.fz,ans.fm);
ans.fz = ans.fz / gcd;
ans.fm = ans.fm / gcd;   return ans;

}

void print(const fraction &f)
{
if (f.fm == 1) cout<<f.signf.fz;
else
cout<<f.sign
f.fz<<'/'<<f.fm;
}

int main()
{
int n=2;
//cin>>n;

fraction res={1,0,1};
int z,m;
char slash;
fraction temp={1,0,1};
for(int i=1; i&lt;=n; i++)
{cin&gt;&gt;z&gt;&gt;slash&gt;&gt;m;temp.sign = (z&gt;=0)?1:-1;temp.fz = temp.sign *z;temp.fm = m;res = add(res,temp);
}//res.fm = res.fm *n;int gcd = __gcd(res.fz,res.fm);
res.fz = res.fz / gcd;
res.fm = res.fm / gcd;   print(res);return 0;

}

评测结果
答案正确 (10 分)
测试点得分
测试点 结果 得分 耗时 内存
0 答案正确 3 3.00 ms 324 KB
1 答案正确 3 2.00 ms 328 KB
2 答案正确 3 3.00 ms 444 KB
3 答案正确 1 2.00 ms 320 KB

7-8
有理数均值
(10分)

本题要求编写程序,计算N个有理数的平均值。

输入格式:

输入第一行给出正整数N(≤\le≤100);第二行中按照a1/b1 a2/b2 …的格式给出N个分数形式的有理数,其中分子和分母全是整形范围内的整数;如果是负数,则负号一定出现在最前面。

输出格式:

在一行中按照a/b的格式输出N个有理数的平均值。注意必须是该有理数的最简分数形式,若分母为1,则只输出分子。

输入样例1:

4
1/2 1/6 3/6 -5/10

输出样例1:

1/6

输入样例2:

2
4/3 2/3

输出样例2:

1
编译器
GXX
代码
#include <bits/stdc++.h>
using namespace std;
struct fraction
{int sign;int fz;int fm;
};

fraction add(const fraction &a, const fraction &b)
{
fraction ans;
if (a.sign == b.sign)
{
ans.sign = a.sign;
ans.fz = a.fzb.fm+a.fmb.fz;
ans.fm = a.fm * b.fm;
}
else
{
ans.fz = a.sign * a.fzb.fm + a.fmb.signb.fz;
ans.fm = a.fm
b.fm;
ans.fz < 0 ? ans.sign = -1, ans.fz=-ans.fz: ans.sign=1;

}
int gcd = __gcd(ans.fz,ans.fm);
ans.fz = ans.fz / gcd;
ans.fm = ans.fm / gcd;   return ans;

}

void print(const fraction &f)
{
if (f.fm == 1) cout<<f.signf.fz;
else
cout<<f.sign
f.fz<<'/'<<f.fm;
}

int main()
{
int n;
cin>>n;

fraction res={1,0,1};
int z,m;
char slash;
fraction temp={1,0,1};
for(int i=1; i&lt;=n; i++)
{cin&gt;&gt;z&gt;&gt;slash&gt;&gt;m;temp.sign = (z&gt;=0)?1:-1;temp.fz = temp.sign *z;temp.fm = m;res = add(res,temp);
}res.fm = res.fm *n;int gcd = __gcd(res.fz,res.fm);
res.fz = res.fz / gcd;
res.fm = res.fm / gcd;   print(res);return 0;

}

评测结果
答案正确 (10 分)
测试点得分
测试点 结果 得分 耗时 内存
0 答案正确 4 3.00 ms 448 KB
1 答案正确 2 3.00 ms 448 KB
2 答案正确 2 3.00 ms 444 KB
3 答案正确 2 3.00 ms 436 KB

7-9
排列枚举
(10分)

口袋里有红、蓝、黄、黑4种颜色的球若干,每次从口袋先后取出3个球,问得到3种不同颜色的球的可能取法,输出每种排列的情况。球只能是4种颜色之一,而且判断各球是否同色,可以用枚举类型变量处理。

输入格式:

输出格式:

输出所有排列。

输入样例:

在这里给出一组输入。例如:

输出样例:

在这里给出相应的输出。例如:

1 red blue yellow
2 red blue black
3 red yellow blue
4 red yellow black
5 red black blue
6 red black yellow
7 blue red yellow
8 blue red black
9 blue yellow red
10 blue yellow black
11 blue black red
12 blue black yellow
13 yellow red blue
14 yellow red black
15 yellow blue red
16 yellow blue black
17 yellow black red
18 yellow black blue
19 black red blue
20 black red yellow
21 black blue red
22 black blue yellow
23 black yellow red
24 black yellow blue
编译器
GXX
代码
#include <bits/stdc++.h>

using namespace std;

enum color{red,blue,yellow,black};
string color_arr[4]={"red","blue","yellow","black"};

int main()
{
int cnt = 0;
for(int i=red;i<=black;i++)
{
for(int j = red;j<=black;j++)
{
for(int k = red;k<=black;k++)
{
if(i!=j&&j!=k&&i!=k)
{
cnt++;
cout<<cnt<<" "<<color_arr[i]<<" "<<color_arr[j]<<" "<<color_arr[k]<<endl;
}
}
}
}

return 0;

}

评测结果
答案正确 (10 分)
测试点得分
测试点 结果 得分 耗时 内存
1 答案正确 10 3.00 ms 440 KB

东北大学acm暑期夏令营结构体相关推荐

  1. 东北大学acm暑期夏令营第七天

    部分内容参考:点我 第一题 #include <bits/stdc++.h> using namespace std; int main() {int sum=0,a;while(cin& ...

  2. 东北大学acm暑期夏令营第八天

    部分内容参考:点我 第一题 double dist( double x1, double y1, double x2, double y2 ) {return sqrt((x1-x2)*(x1-x2) ...

  3. ACM 常用技巧 结构体排序 粗粗粗粗讲

    首先说下结构体这种东西,就是,具有同种结构的一堆变量,可以塞到一个叫struct的东西里,声明方法如下.(ps. 别忘了加头文件<cstdlib>)再透露一下,由于本人代码能力菜的一*,所 ...

  4. acm新手小白必看系列之(1)——二维数组及结构体精讲附带例题

    *acm新手小白必看系列之(1)--二维数组及结构体 ** c++准备工作** (可能小白像我一样也是学习的c语言) 万能头文件,放在第一行 #include<bits/stdc++.h> ...

  5. 【HDU】1084 What Is Your Grade? (结构体 sort)

    http://acm.hdu.edu.cn/showproblem.php?pid=1084 题目的关键: 1.Note, only 1 student will get the score 95 w ...

  6. 【20保研】中南大学计算机学院2019年全国优秀大学生暑期夏令营通知

    点击文末的阅读原文或者公众号界面左下角的保研夏令营或者公众号回复"夏令营"是计算机/软件等专业的所有保研夏令营信息集合,会一直更新的. 为进一步提高我院研究生生源质量,改善生源结构 ...

  7. 向大佬学习C语言1198: 考试排名(二)(结构体专题)

    题目 1198: 考试排名(二)(结构体专题) 时间限制: 1 Sec 内存限制: 128 MB 提交: 3737 解决: 728ACM 国际大学生程序设计竞赛,英文全称:ACM Internatio ...

  8. ZZULIOJ1198: 考试排名(二)(结构体专题)

    1198: 考试排名(二)(结构体专题) 题目描述: ACM 国际大学生程序设计竞赛,英文全称:ACM International Collegiate Programming Contest(ACM ...

  9. 1198: 考试排名(二)(结构体专题)

    1198: 考试排名(二)(结构体专题) 题目描述 ACM 国际大学生程序设计竞赛,英文全称:ACM International Collegiate Programming Contest(ACM- ...

最新文章

  1. IOS长按识别二维码失败
  2. 【Oracle】表空间相关集合
  3. 深入学习Heritrix---解析CrawlController
  4. Android 将ARGB图片转换为灰度图
  5. 如何给Lombok Builder提供默认值
  6. 约瑟夫环 java实现
  7. python0b1011_1011 A+B 和 C (15分)Python参考答案
  8. cvc降噪和主动降噪_小米降噪项圈蓝牙耳机来了:Hybrid主动降噪技术
  9. 从0开始写JavaWeb框架系列(1)从0开始写SamrtFrameWork:读取配置文件
  10. StdC--12 结构体
  11. 设计一个三阶巴特沃斯滤波器_巴特沃斯低通滤波器设计分析.doc
  12. python输入生日输出星座_怎么利用python输出星座
  13. 苹果logo_苹果 ARM Mac 发布会独特标志 Logo 亮相
  14. 东鹏饮料,有点“上头”
  15. Android蓝牙源码分析——BTA层消息分发
  16. EOS主网上线后imtoken钱包和麦子钱包的操作
  17. 好程序员Java分享MySQL之SQL入门(一)
  18. Android/iOS视频编辑SDK开发记
  19. Java基础回归之注解Annotation【低仿ButterKnife实战篇】
  20. Dalsa智能相机使用流程

热门文章

  1. ionic3开发系列——实现对手机软件键盘按键的监听
  2. 【阿里云】阿里云日志查询语法
  3. Rk3128 按键驱动
  4. 【挖矿木马】记一次被挖矿木马攻击的过程(Redis被攻击)
  5. Excel和XML的相互转换(JAVA语言)
  6. php去除前后空格函数,php去除前后空格的实现方法
  7. 即将开学,为校园网络安全助力
  8. 如何学习单片机编程?
  9. [原创]插卡路由器对接openwrt对接国内节点 手机免流通过USB口共享流量给路由器教程
  10. 系统分析师教程——目录