YTU 2432: C++习题 对象数组输入与输出
来源:互联网 发布:淘宝虚拟物品货源 编辑:程序博客网 时间:2024/06/07 10:44
2432: C++习题 对象数组输入与输出
时间限制: 1 Sec 内存限制: 128 MB提交: 1603 解决: 1152
题目描述
建立一个对象数组,内放n(n<10)个学生的数据(学号、成绩),用指针指向数组首元素,输出第奇数(1,3,5,7)个学生的数据。
输入
n和n个学生的学号、成绩
输出
奇数学生的数据
样例输入
5101 78.5102 85.5103 98.5104 100.0105 95.5
样例输出
101 78.50103 98.50105 95.50
提示
主函数已给定如下,提交时不需要包含下述主函数
/* C++代码 */
int main()
{
const int NUM=10;
Student stud[NUM];
int n,i;
cin>>n;
for(i=0; i<n; i++)
stud[i].input();
cout<<setiosflags(ios::fixed);
cout<<setprecision(2);
Student *p=stud;
for(i=0; i<n; p+=2,i+=2)
p->display();
return 0;
}
迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……
#include <stdio.h>#include <iostream>#include <iomanip>using namespace std;class Student{public: void input() { cin>>num>>a; } void display() { cout<<num<<" "<<a<<endl; } int num; float a;};int main(){ const int NUM=10; Student stud[NUM]; int n,i; cin>>n; for(i=0; i<n; i++) stud[i].input(); cout<<setiosflags(ios::fixed); cout<<setprecision(2); Student *p=stud; for(i=0; i<n; p+=2,i+=2) p->display(); return 0;}
#include <stdio.h>#include <iostream>#include <iomanip>using namespace std;class Student{public: void input() { cin>>num>>a; } void display() { cout<<num<<" "<<a<<endl; } int num; float a;};int main(){ const int NUM=10; Student stud[NUM]; int n,i; cin>>n; for(i=0; i<n; i++) stud[i].input(); cout<<setiosflags(ios::fixed); cout<<setprecision(2); Student *p=stud; for(i=0; i<n; p+=2,i+=2) p->display(); return 0;}
1 0
- YTU 2432: C++习题 对象数组输入与输出
- [YTU]_2432( C++习题 对象数组输入与输出)
- [YTU]_2432 (C++习题 对象数组输入与输出)
- YTU-OJ- 对象数组输入与输出
- C++习题 对象数组输入与输出
- ojC++习题 对象数组输入与输出
- C++习题 对象数组输入与输出
- C++习题 对象数组输入与输出
- YTU 2429: C语言习题 学生成绩输入和输出
- [YTU]_2429( C语言习题 学生成绩输入和输出)
- 2432对象数组输入与输出
- YTU 2416: C语言习题 成绩输出
- YTU 2425: C语言习题 输出月份
- YTU:C语言习题 输出月份
- 对象数组输入与输出
- 对象数组输入与输出
- 第十五周oj刷题——Problem D: C++习题 对象数组输入与输出
- ACM 对象数组输入与输出
- 调试CC2540遇到的小问题
- C++ 拷贝构造函数 赋值构造函数
- windows下MemCached的安装
- template关键字
- POJ NO.1182 食物链(并查集,带权并查集最优解,没有之一)
- YTU 2432: C++习题 对象数组输入与输出
- POJ 3565 Ants(二分图最小权完备匹配)
- poj 1324(BFS+状态压缩)
- Android Studio如何删除module
- 【LeetCode OJ 14】Longest Common Prefix
- 枚举类型模拟
- 学习redis基础命令网站
- Swift中定义protocol,定义optional方法
- Swift开发 底部对话框UIActionSheet