#include<iostream>
using namespace std;
int main()
{
int st;
cout<<"Enter student number :"<<endl;
cin>>st;
int a[st],b[st],i,j,temp;
string name[st];
for(i=0; i<st; i++)
{
cout<<"Enter student nick name and marks separated by space:\t";
cin>>name[i];
cin>>a[i];
b[i]=a[i];
}
cout<<"\n\nYour result sheet is below :\n";
cout<<"---------------------------\n"<<endl;
for(i=0; i<st-1; i++)
{
for(j=0 ; j<st-i-1; j++)
{
if(a[j]<a[j+1])
{
temp= a[j];
a[j]=a[j+1];
a[j+1] = temp;
}
}
}
for(i=0; i<st; i++)
{
cout<<"Roll "<<i+1<<": ";
for(j=0; j<st; j++)
{
if(a[i] == b[j])
{
cout<<name[j]<<"\t";
cout<<a[i]<<endl;
}
}
}
}
using namespace std;
int main()
{
int st;
cout<<"Enter student number :"<<endl;
cin>>st;
int a[st],b[st],i,j,temp;
string name[st];
for(i=0; i<st; i++)
{
cout<<"Enter student nick name and marks separated by space:\t";
cin>>name[i];
cin>>a[i];
b[i]=a[i];
}
cout<<"\n\nYour result sheet is below :\n";
cout<<"---------------------------\n"<<endl;
for(i=0; i<st-1; i++)
{
for(j=0 ; j<st-i-1; j++)
{
if(a[j]<a[j+1])
{
temp= a[j];
a[j]=a[j+1];
a[j+1] = temp;
}
}
}
for(i=0; i<st; i++)
{
cout<<"Roll "<<i+1<<": ";
for(j=0; j<st; j++)
{
if(a[i] == b[j])
{
cout<<name[j]<<"\t";
cout<<a[i]<<endl;
}
}
}
}
No comments:
Post a Comment
Thank you for commenting. Please wait for response :)