Hey,

Hope you are doing well.I am absolutely a new programmer.I have been facing trouble for couple of days.I am exercising "52 programming problems and Solution" By tamim Shariar Subin.

In program number 8,I am facing trouble to sort the number.I can sort numbers,but I am unable to get from users' input.Can anyone tell me how to do that ?Please give me the full code.I am really very disappointed

Thanks Khan

asked 28 Feb '16, 10:13

AhadKhan's gravatar image

AhadKhan
95219

1

আপনার কোড সহ প্রশ্ন করেন

(28 Feb '16, 12:16) menon
1

প্রথমে কতটুকু চেষ্টা করেছ, সেটা জানতে হবে, তাই তোমার কোড শেয়ার কর।

(28 Feb '16, 13:41) Tamim Shahriar Subeen ♦♦

-1
int main(){
    int i,j,kase,t,sorted,temp;
    int ara[1000];
    scanf("%d",&t);
    for(kase=1;kase<=t;kase++){
        for(i=0;i<3;i++){
            scanf("%d",&ara[i]);
        }
            while(1){
                sorted=0;
                for(j=0;j<3;j++){
                if(ara[j]>ara[j+1]){
                    temp=ara[j];
                    ara[j]=ara[j+1];
                    ara[j+1]=temp;
                    sorted=1;
                }
                }

                if(sorted==0){
                    break;
                }
            }
            for(i=0;i<3;i++){
                printf("%d",ara[i]);
            }
    }
}
permanent link

answered 28 Feb '16, 17:42

AhadKhan's gravatar image

AhadKhan
95219

edited 28 Feb '16, 18:40

__salman__'s gravatar image

__salman__ ♦♦
1.1k211

1

ভাই কোডটা একটু এডিট করে ইন্ডেন্ট করে দেন

(28 Feb '16, 17:51) menon

Paste korle kemon jeno hibijibi hoy ,taw abar ditesi

(28 Feb '16, 18:38) AhadKhan

কোড ফরম্যাটিং এত সহজ তাও এখানে এত ভুল কিভাবে হয়?

(28 Feb '16, 18:40) __salman__ ♦♦
-1
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(){
    int i,j,kase,t,temp,sorted,l;
    int ara[100];
    scanf("%d",&t);
    for(kase=1;kase<=t;kase++){
        for(i=0;i<3;i++){
            scanf("%d",&ara[i]);

        }
        printf("Case %d:",kase);
        while(1){
            sorted=0;
            for(j=0;j<3;j++){
                if(ara[j]>ara[j+1]){
                    temp=ara[j];
                    ara[j]=ara[j+1];
                    ara[j+1]=temp;
                    sorted=1;
                }
            }
            if(sorted==0){
                break;
            }
        }

        for(l=0;l<3;l++){
            printf(" %d",ara[l]);

        }
        printf("\n");
    }
    return 0;

}
permanent link

answered 28 Feb '16, 18:37

AhadKhan's gravatar image

AhadKhan
95219

edited 28 Feb '16, 18:39

__salman__'s gravatar image

__salman__ ♦♦
1.1k211

এটি মনে প্রশ্নের সাথে attach হবে।

(29 Feb '16, 06:37) Kaiser Ahmed
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×402
×212
×54

question asked: 28 Feb '16, 10:13

question was seen: 3,315 times

last updated: 29 Feb '16, 06:37