Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 100
- struct twitter{
- char nombre[120];
- int tweets,retweets;
- };
- void burbuja(int a, struct twitter users[]);
- int main(){
- int i=0;
- struct twitter users[100];
- for (i=0;i<SIZE;i++){
- printf ("Ingrese los datos para el %iĀ° usuario:\n", i+1);
- printf ("Nombre: ");
- scanf ("%s", users[i].nombre);
- printf ("\nTweets: ");
- scanf ("%d", &users[i].tweets);
- printf ("\nRetweets: ");
- scanf ("%d", &users[i].retweets);
- }
- printf ("Tweets desordenados: \n");
- for (i=0;i<SIZE;i++){
- printf ("Nombre: %s\nTWEETS: %d\nRetweets: %d\n", users[i].nombre,users[i].tweets, users[i].retweets);
- }
- burbuja(SIZE,users);
- printf ("\n-----------------------------\n");
- printf ("Tweets desordenados: \n");
- for (i=0;i<SIZE;i++){
- printf ("Nombre: %s\nTWEETS: %d\nRetweets: %d\n", users[i].nombre,users[i].tweets, users[i].retweets);
- }
- return 0;
- }
- void burbuja(int a, struct twitter users[]){
- int p, j;
- struct twitter aux;
- for (p=1;p<SIZE;p++){
- for (j=0;j<SIZE-1;j++){
- if (users[j].tweets>users[j+1].tweets){
- aux=users[j];
- users[j]=users[j+1];
- users[j+1]=aux;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement