Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package alg;
- /**
- *
- * @author Bam
- */
- public class Main {
- /*
- * x od 0 do range
- * y od -range do range
- */
- public static int range = 10000;
- // ax +- by = result
- public static int a = 5;
- public static int b = 7;
- public static int result = 1829;
- // jesli NWD nie jest podany musi rownac sie 0
- public static int NWD = 59;
- /* znak rownania
- * 'p' plus
- * 'm' minus
- */
- public static char sign = 'p';
- public static void main(String[] args) {
- for(int x = 0; x < range; x++)
- for(int y = -range; y < range; y++ ){
- int res = 0;
- if( sign == 'p' ) res = a * x + b * y;
- else if( sign == 'm') res = a * x - b * y;
- else System.exit(0);
- if( res == result ){
- if( NWD != 0 ){
- if( x % NWD == 0 && y % NWD == 0 )
- System.out.println("x: " + x + " | y: " + y + " |for: " + result);
- }else{
- System.out.println("x: " + x + " | y: " + y + " |for: " + result);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement