Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, x Select Case x Case Is >= 10000 Print #2, x * 0.55 Case Is >= 5000 Print #2, x * 0.6 Case Is >= 1000 Print #2, x * 0.7 Case Else: Print #2, x End Select Loop Close Close End End Sub
try{ DataInputStream isr= new DataInputStream(new FileInputStream(file)); BufferedReader b = new BufferedReader(new InputStreamReader(isr)); FileOutputStream A = new FileOutputStream(Fo); OutputStreamWriter out = new OutputStreamWriter(A); int i ;
while(in !=null){ in = b.readLine(); if (in != null){ int ans = Integer.parseInt(in); ans = S(ans); String Ans = String.valueOf(ans); System.out.println(Ans); out.write(Ans); out.write("\r\n"); } } out.close(); } catch(Exception e){} }
public static int S(int n){
if (n>=2000 & n<5000){ n= n*7 /10 ; } if (n>=5000 & n<10000){ n= n*6 /10 ; } if (n>=10000){ n= n*55 /100 ; }
Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, n ans = 0 Select Case n Case Is >= 10000 ans = n * 0.55 Case Is >= 5000 ans = n * 0.6 Case Is >= 2000 ans = n * 0.7 Case Else: ans = n End Select Print #2, ans Loop Close #2 Close #1 End End Sub
Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, x If x < 2000 Then Print #2, x Else Select Case x Case Is >= 10000 Print #2, x * 0.55 Case Is >= 5000 Print #2, x * 0.6 Case Is >= 2000 Print #2, x * 0.7 End Select End If Loop Close #2 Close #1 End End Sub
Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, n n = Val(n) If n > 2000 And n <= 5000 Then n = n * 0.7 If n > 5000 And n <= 10000 Then n = n * 0.6 If n > 10000 Then n = n * 0.55 Print #2, n Loop Close #2 Close #1 End End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, x
Select Case x
Case Is >= 10000
Print #2, x * 0.55
Case Is >= 5000
Print #2, x * 0.6
Case Is >= 1000
Print #2, x * 0.7
Case Else: Print #2, x
End Select
Loop
Close
Close
End
End Sub
package work;
回覆刪除import java.io.*;
public class Work{
public static void main(String[] args) {
String file = "c:\\test.txt";
String Fo = "c:\\out.txt";
String in="0";
try{
DataInputStream isr= new DataInputStream(new FileInputStream(file));
BufferedReader b = new BufferedReader(new InputStreamReader(isr));
FileOutputStream A = new FileOutputStream(Fo);
OutputStreamWriter out = new OutputStreamWriter(A);
int i ;
while(in !=null){
in = b.readLine();
if (in != null){
int ans = Integer.parseInt(in);
ans = S(ans);
String Ans = String.valueOf(ans);
System.out.println(Ans);
out.write(Ans);
out.write("\r\n");
}
}
out.close();
}
catch(Exception e){}
}
public static int S(int n){
if (n>=2000 & n<5000){
n= n*7 /10 ;
}
if (n>=5000 & n<10000){
n= n*6 /10 ;
}
if (n>=10000){
n= n*55 /100 ;
}
return n;
}
}
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, n
ans = 0
Select Case n
Case Is >= 10000
ans = n * 0.55
Case Is >= 5000
ans = n * 0.6
Case Is >= 2000
ans = n * 0.7
Case Else: ans = n
End Select
Print #2, ans
Loop
Close #2
Close #1
End
End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, x
If x < 2000 Then
Print #2, x
Else
Select Case x
Case Is >= 10000
Print #2, x * 0.55
Case Is >= 5000
Print #2, x * 0.6
Case Is >= 2000
Print #2, x * 0.7
End Select
End If
Loop
Close #2
Close #1
End
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, n
n = Val(n)
If n > 2000 And n <= 5000 Then n = n * 0.7
If n > 5000 And n <= 10000 Then n = n * 0.6
If n > 10000 Then n = n * 0.55
Print #2, n
Loop
Close #2
Close #1
End
End Sub