的另一個結構的元件如果存在的結構:複製結構陣列的至相同類型的
struct Student // Student structure to store student's records
{
int rollno; // student rollno
string name; // student name
string address; // address
int pno; // phone number
};
和INT主()包含
int main()
{
Student *s;
s= new Student [10];
}
然後我們如何可以分配一個結構給相同類型的不同結構?
void arrange()
{
Student *p= new Student;
// int temp;
for (int i=0; i<10; i++)
{
for (int j=0; j<10; j++)
{
if (i != j)
{
if (s[i].rollno > s[j].rollno)
{
p = s[i];
s[i] = s[j];
s[j] = p;
}
}
}
}
您不能在標記格式化代碼中使用** bold **格式。使用'* p = s [i];'和'[j] = * p;'來分配/從'p'。 –
沒有必要用粗體書寫所有的東西。 – hivert
謝謝....這是我第一次使用...這就是爲什麼... – Shaan