import javax.swing.*;
import java.util.*;
import java.io.*;
public class my6 {
public static void main(String[] args) throws IOException{
Scanner sc=new Scanner(new File("a.txt"));
PrintWriter pw=new PrintWriter(new File("b.txt"));
String s=sc.nextLine();
int k=0; int j,i;int m=0;
for (i=1;i<=s.length();i++)
k++;
pw.println("satr uzunligi k="+k);
sc.close();pw.close();
}
}
Natija :a.txt salom
b.txt 5
Biz fayllar bilan ishlaganda faqat satr yoki matn bilan ishlashimiz shart emas
xoxlagan turdagi dasturni tuza olamiz,bu dastur n-chi tub sonni topib beradi.
import javax.swing.*;
import java.io.*;
import java.util.*;
public class my7 {
public static void main(String[] args) throws IOException{
Scanner sc=new Scanner(new File("a.txt"));
PrintWriter pw=new PrintWriter(new File("b.txt"));
int n=sc.nextInt();
int j,k,t,m=0;
int i;
for (i=2;true;i++){ k=0;
for (j=2;j<=Math.sqrt(i);j++)
Do'stlaringiz bilan baham: |