forked from Assasincoderzz/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp1.java
34 lines (34 loc) · 884 Bytes
/
p1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.Scanner;
import java.io.*;
public class p1
{
public static void main(String[] args) throws Exception
{
int n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
int[] arr = new int[n];
for(int i=0; i<n; i++)
{
arr[i]=sc.nextInt();
}
FileWriter writer = new FileWriter("input.txt");
int len = arr.length;
for (int i = 0; i < len; i++)
{
writer.write(arr[i]);
}
writer.close();
FileReader reader = new FileReader("input.txt");
int nu;
int s=0;
for (int i = 0; i < len; i++)
{
nu=reader.read();
System.out.print(nu+" ");
s+=nu;
}
System.out.print(s);
reader.close();
}
}