输入两个整数,范围-231~231-1,交换两个数并输出。
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); String[] r = s.split("[=,]"); //分割后的字符串只剩下字母和数字 System.out.println("a="+r[3]+",b="+r[1]); } }
import java.util.Scanner; import java.io.IOException; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String[] data = sc.nextLine().split(","); String a = data[0].substring(2); String b = data[1].substring(2); System.out.println("a="+b+","+"b="+a); } }
import java.util.Scanner; import java.io.IOException; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String data = sc.nextLine(); int index = data.indexOf(","); String a = data.substring(2, index); String b = data.substring(index+3); System.out.println("a="+b+","+"b="+a); } }
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); String[] split = scanner.nextLine().split(","); String[] str1 = split[0].split("="); String number1=str1[1]; String[] str2 = split[1].split("="); String number2=str2[1]; System.out.println("a="+number2+",b="+number1); } }
#include <stdio.h> void swap(void*x,void*y,char size) { char*p_x=(char*)x; char*p_y=(char*)y; char temp; for(char i=0;i<size;i++) { temp=*(p_x+i); *(p_x+i)=*(p_y+i); *(p_y+i)=temp; } } int main() { int a,b; scanf("a=%d,b=%d",&a,&b); swap(&a,&b,sizeof(int)); printf("a=%d,b=%d",a,b); return 0; }
a,b = input().split(',') print ('a=%s,b=%s'%(b[2:],a[2:]))