C语言
```c
include
int main() {
int a, b, c, t;
printf("请输入三个整数:a b c\n");
scanf("%d%d%d", &a, &b, &c);
if (a > b) {
t = a;
a = b;
b = t;
}
if (a > c) {
t = a;
a = c;
c = t;
}
if (b > c) {
t = b;
b = c;
c = t;
}
printf("排序后的三个整数为:%d,%d,%d\n", a, b, c);
return 0;
}
```
C++
```cpp
include
int main() {
int a, b, c;
std::cout << "请输入三个整数:a b c" << std::endl;
std::cin >> a >> b >> c;
if (a > b) {
int t = a;
a = b;
b = t;
}
if (a > c) {
int t = a;
a = c;
c = t;
}
if (b > c) {
int t = b;
b = c;
c = t;
}
std::cout << "排序后的三个整数为:"<< a << ","<< b << ","<< c << std::endl;
return 0;
}
```
Java
```java
public class PrintABC {
private static Object lock = new Object();
private static int count = 0;
public static void main(String[] args) {
Thread t1 = new Thread(new PrintThread('a', 0));
Thread t2 = new Thread(new PrintThread('b', 1));
Thread t3 = new Thread(new PrintThread('c', 2));
t1.start();
t2.start();
t3.start();
}
static class PrintThread implements Runnable {
private char ch;
private int flag;
public PrintThread(char ch, int flag) {
this.ch = ch;
this.flag = flag;
}
@Override
public void run() {
synchronized (lock) {
if (count == flag) {
System.out.print(ch);
count = (flag + 1) % 3;
lock.notifyAll();
} else {
try {
lock.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
}
```
Python
```python
import threading
def print_abc():
global order
order = 'abc'
for char in order:
print(char, end='')
threading.Event().wait(1)
t1 = threading.Thread(target=print_abc)
t2 = threading.Thread(target=print_abc)
t3 = threading.Thread(target=print_abc)
t1.start()
t2.start()
t3.start()
t1.join()
t2.join()
t3.join()
```
这些示例代码分别展示了如何在C、C++、Java和Python中实现按顺序输出a、b、c的值。你可以根据自己的需求和编程环境选择合适的代码进行尝试。