Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void sort();
- int main()
- {
- int num[3],temp;
- char word[4];
- scanf("%d %d %d",&num[0],&num[1],&num[2]);
- scanf("%s",word);
- sort(num[0],num[1],num[2]);
- if(word[0] == 'A' && word[1] == 'C')
- {
- temp = num[1];
- num[1] = num[2];
- num[2] = temp;
- }
- else if(word[0] == 'B' && word[1] == 'A')
- {
- temp = num[0];
- num[0] = num[1];
- num[1] = temp;
- }
- else if(word[0] == 'B' && word[1] == 'C')
- {
- temp = num[0];
- num[0] = num[2];
- num[2] = num[1];
- num[1] = temp;
- }
- else if(word[0] == 'C' && word[1] == 'A')
- {
- temp = num[0];
- num[0] = num[1];
- num[1] = num[2];
- num[2] = temp;
- }
- else if(word[0] == 'C' && word[1] == 'B')
- {
- temp = num[0];
- num[0] = num[2];
- num[2] = temp;
- }
- printf("%d %d %d",num[1],num[1],num[2]);
- void sort(num[0],num[1],num[2]);
- {
- int i,j,temp;
- for(i=0;i<=1;i++)
- {
- for(j=0;j<=1;j++)
- {
- if(num[j]>num[j+1])
- {
- temp = num[j];
- num[j] = num[j+1];
- num[j+1] = temp;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement