使用数组和冒泡排序的成绩簿程序(很多问题) [英] Grade book program using arrays and Bubble sort (many problems)

查看:99
本文介绍了使用数组和冒泡排序的成绩簿程序(很多问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一本gradbook类型的程序。它首先允许用户输入他们想要输入的学生数量。然后允许他们输入每个学生的名字,姓氏和成绩。然后,程序应按姓氏的字母顺序对名称进行排序,并按字母顺序显示所有学生姓名和成绩的列表。我已经完成了所有的功能和课程,但是我收到了大量的错误,我不确定是什么问题。这是我第一次尝试使用类和对象以及冒泡排序,所以我不确定。这是我的代码让我知道你看到的任何问题,我将非常感谢一些指导。首先是头文件

I am writing a gradbook type program. It first allows the user to enter the number of students they want to enter. then allows them to enter the first name, last name, and grade of each student. The program then should sort the names alphabetically by last name and display a list of all the students names and grades in alphabetical order. I have completed all my functions and classes, but i am getting a god aweful amount of errors and i am not sure what is wrong. It is my first attempt at using classes and objects and bubble sort so i am not sure. here is my code let me know any problems you see, i would greatly appreciate some guidance. First is the header file

展开 | 选择 | Wrap | 行号

推荐答案

我立刻注意到两件事:


1)这是C ++(正如我从你看到的那样使用字符串,cin,cout等),那你为什么要使用char *来保存名字呢?这就是std :: strings的用途。


2)在你的main()中,你试图在一个对象上调用方法,但是你还没有做到学生对象。您需要说:

Two things I immediately notice:

1) This is C++ (as I see from you using strings, cin, cout, etc.), so why are you using char* to hold names and such? That''s what std::strings are for.

2) In your main(), you are trying to call methods on an object, but you haven''t made a student object. You need to say:

展开 | 选择 | Wrap | 行号


感谢帮助人员,我摆脱了所有错误,该程序现在运行。当它运行时,它只打印出getData()cout东西100次,然后打印出学生姓氏:接下来是一堆乱七八糟的东西。该计划要求该计划向用户提供他们想要输入的学生人数,这是我这样做的唯一原因。我已经说出了泡沫的类型,因为我不知道如何对它进行排序。任何有助于使程序更好地工作的帮助都将被编程。这就是我现在所拥有的,
thanks for the help man, i got rid of all the errors and the program "runs'' now. When it runs it just prints out getData() cout stuff 100 times, and then prints out Student Last name: folloed by a bunch of jibberish. The program requirments call for the program to promt the user for the number of students they would like to enter, that is the only reason i did it like that. I have commened out the bubble sort, becaussei can''t figure out how to make it sort the last names. Any help with with getting the program working better would be apprecriated. here is what i have now,
展开 | 选择 | Wrap | 行号


快速注释:它是< string>,而不是< string.h> 。你知道标准标题是如何工作的,不是吗?


那么,你做了什么来弄清问题区域在哪里?拿你的非工作程序,把它丢弃在我们面前,然后说出弄清楚什么是错的,这是不好的。
Quick note: it''s <string>, not <string.h> . You do know how standard headers work, do you not?

So, what have you done to figure out where the problem areas are? It''s not nice to take your non working program, dump it on us, and say "figure out what''s wrong please".


这篇关于使用数组和冒泡排序的成绩簿程序(很多问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆