-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem1.php
More file actions
311 lines (281 loc) · 12 KB
/
problem1.php
File metadata and controls
311 lines (281 loc) · 12 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?php
if(session_status()==PHP_SESSION_NONE)
{
session_start();
if(!isset($_SESSION['username']))
{
header("Location: index.php");
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/Semantic/semantic.min.css">
<script src="js/jquery-3.4.1.min.js"></script>
<script src="css/Semantic/semantic.min.js"></script>
<script src="js/script.js"></script>
<script src="js/questions.js"></script>
<link rel="stylesheet" href="css/home.css">
<link rel="icon" href="images\dscelogo.png">
<title>Problem 1</title>
</head>
<body>
<h1 class="ui header" style="text-align:center" id = "head">
<a class="ui circular image" href="http://dsce.edu.in"><img src="images/dscelogo.jpg"></a>
<a href="titles.php">Virtual Labs</a>
</h1>
<div id="toTop"><i class="chevron up icon"></i></div>
<div>
<div class="ui light grey inverted secondary huge menu">
<a class="header item" href="index.php">
Home
</a>
<a class="item" href="placement.php">
Placement Training
</a>
<a class="item">
About Us
</a>
<!-- <a class="item">
Item
</a> -->
</div>
</div>
<div class="ui container" id="cont">
<h2 class="ui header" style="font-size:35px; margin-left:10px;">
Game of numbers
</h2>
<div class="ui stackable grid">
<div class="four wide column">
<div class="ui secondary vertical pointing menu" id="Menus">
<a class="active item" id="intro">
Introduction
</a>
<a class="item" id="list">
Compiler
</a>
<a class="item" id="faq">
Quiz
</a>
</div>
</div>
<div class="twelve wide stretched column">
<div class="ui segment">
<div id="int">
Pre-requisites: Arrays.
</div>
<div id="lis" style="display: none;">
<div class="ui form">
<div id="compilerData">
Gurudeep is a brilliant boy. He likes memory games. He likes to participate alone but this time he has to have a partner. So he chooses you.<br><br>
In this Game , your team will be shown <strong>N numbers</strong> for few minutes . You will have to memorize these numbers.
<br><br>
Now, the questioner will ask you <strong>Q queries</strong>, in each query He will give you a number , and you have to tell him <strong>the total number of occurrences of that number in the array of numbers shown to your team </strong>. If the number is not present , then you will have to say <strong>“NOT PRESENT”</strong> (without quotes).<br><br>
<strong>Input and Output:</strong><br><br>
The first line of input will contain N, an integer, which is the total number of numbers shown to your team.<br><br>
The second line of input contains N space separated integers .<br><br>
The third line of input contains an integer Q , denoting the total number of integers.<br><br>
The Next Q lines will contain an integer denoting an integer, Bi, for which you have to print the number of occurrences of that number (Bi) in those N numbers on a new line.<br><br>
If the number Bi isn’t present then Print “NOT PRESENT” (without quotes) on a new line.<br><br>
</div><br>
<div class="ui segment">
<div class="ui two column very relaxed grid">
<div class="column">
<strong>Sample Input</strong><br>
<pre>6
1 1 1 2 2 0
6
1
2
1
0
3
4
</pre>
</div>
<div class="column">
<strong>Sample Output</strong><br>
<pre>3
2
3
1
NOT PRESENT
NOT PRESENT<br>
</pre>
</div>
</div>
<div class="ui vertical divider"></div>
</div>
</div><br>
<div class="ui form"><strong>Explanation</strong><br><br>
The given array is (1,1,1,2,2,0) of size 6.
<br><br>
Total number of queries is 6 also.
<br><br>
For the first query i.e for 1 , the total of number of occurrences of 1 in the given array is 3 . Hence the corresponding output is 3.
<br><br>
For the second query i.e. for 2, the total of number of occurrences of 2 in the given array is 2 . Hence the corresponding output is 2.
<br><br>
For the fifth query i.e. for 3. 3 is not present in the array . So the corresponding output is "NOT PRESENT" (without quotes).
<br><br>
</div>
<form action="compile.php" id="form" name="f2" method="POST" ><br>
<label class="writeCode" for="lang">Choose Language<br></label>
<select class="ui dropdown" name="lang" style="margin-left: 30px;">
<option class="item" value="c">C</option>
<option class="item" value="cpp">C++</option>
<option class="item" value="java">Java</option>
<option class="item" value="py2">Python 2.7</option>
<option class="item" value="py3">Python 3.2</option>
</select><br><br>
<label class="writeCode">Write Your Code</label><br><br>
<div class="ui large segment" style="height:500px; font-size: 20px">
<div id="editor">/*Type your code here: */
</div>
</div>
<div>
<textarea name="editor" style="display: none;" >
</div>
<textarea style="display: none;"></textarea>
<button class="ui left floated button" onclick="myFunction()">Custom Input</button>
<div id="inputs" style="display:None;">
<br><br>
<label for="in" class="writeCode"><br>Enter Your Input</label><br><br>
<textarea class="field codeBlock" name="input" rows="5" cols="50"></textarea><br><br><br>
</div>
<input type="hidden" name="extra" value="Content of the extra variable" >
<input type="hidden" name="prog" value="problem1">
<input type="submit" id="st" class="ui left floated button" value="Run Code" onclick="myFunction2()">
<input type="submit" id="subb" class="ui left floated button" value="Submit" onclick="myFunction2()"><br><br><br>
</form>
<script type="text/javascript">
$(document).ready(function(){
$("#st").click(function(){
$("#outputBox").html("<div class=\"writeCode\">Loading ......</div>");
document.f2.extra.value = "runn";
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#subb").click(function(){
$("#outputBox").html("<div class=\"writeCode\">Loading ......</div>");
document.f2.extra.value = "subb";
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
//listen for form submission
$('form').on('submit', function(e){
//prevent form from submitting and leaving page
e.preventDefault();
// AJAX
$.ajax({
type: "POST", //type of submit
cache: false, //important or else you might get wrong data returned to you
url: "compile.php", //destination
datatype: "html", //expected data format from process.php
data: $('form').serialize(), //target your form's data and serialize for a POST
success: function(result) { // data is the var which holds the output of your process.php
// locate the div with #result and fill it with returned data from process.php
$('#outputBox').html(result);
}
});
});
});
</script>
<br>
<div id="outputBox" style="display:None;">Output:<br><br>
<div name="output"></div><br>
</div>
</div>
</div>
<div id="faqs" style="display: none;">
<form name="Quiz1">
<p>1. Yes?<br>
<label><input type="radio" name="q1" value="Ok">Ok</label><br>
<label><input type="radio" name="q1" value="Sure">Sure</label><br>
<label><input type="radio" name="q1" value="Kewl">Kewl</label><br>
<label><input type="radio" name="q1" value="Aythu">Aythu</label><br>
<span id="q1"></span>
</p><br>
<p>2. Yes?<br>
<label><input type="radio" name="q2" value="Ok">Ok</label><br>
<label><input type="radio" name="q2" value="Sure">Sure</label><br>
<label><input type="radio" name="q2" value="Kewl">Kewl</label><br>
<label><input type="radio" name="q2" value="Aythu">Aythu</label><br>
<span id="q2"></span>
</p><br>
<p>3. Yes?<br>
<label><input type="radio" name="q3" value="Ok">Ok</label><br>
<label><input type="radio" name="q3" value="Sure">Sure</label><br>
<label><input type="radio" name="q3" value="Kewl">Kewl</label><br>
<label><input type="radio" name="q3" value="Aythu">Aythu</label><br>
<span id="q3"></span>
</p><br>
<p>4. Yes?<br>
<label><input type="radio" name="q4" value="Ok">Ok</label><br>
<label><input type="radio" name="q4" value="Sure">Sure</label><br>
<label><input type="radio" name="q4" value="Kewl">Kewl</label><br>
<label><input type="radio" name="q4" value="Aythu">Aythu</label><br>
<span id="q4"></span>
</p><br>
<p>5. Yes?<br>
<label><input type="radio" name="q5" value="Ok">Ok</label><br>
<label><input type="radio" name="q5" value="Sure">Sure</label><br>
<label><input type="radio" name="q5" value="Kewl">Kewl</label><br>
<label><input type="radio" name="q5" value="Aythu">Aythu</label><br>
<span id="q5"></span>
</p><br>
<p>6. Yes?<br>
<label><input type="radio" name="q6" value="Ok">Ok</label><br>
<label><input type="radio" name="q6" value="Sure">Sure</label><br>
<label><input type="radio" name="q6" value="Kewl">Kewl</label><br>
<label><input type="radio" name="q6" value="Aythu">Aythu</label><br>
<span id="q6"></span>
</p><br>
<p>7. Yes?<br>
<label><input type="radio" name="q7" value="Ok">Ok</label><br>
<label><input type="radio" name="q7" value="Sure">Sure</label><br>
<label><input type="radio" name="q7" value="Kewl">Kewl</label><br>
<label><input type="radio" name="q7" value="Aythu">Aythu</label><br>
<span id="q7"></span>
</p><br>
<p>8. Yes?<br>
<label><input type="radio" name="q8" value="Ok">Ok</label><br>
<label><input type="radio" name="q8" value="Sure">Sure</label><br>
<label><input type="radio" name="q8" value="Kewl">Kewl</label><br>
<label><input type="radio" name="q8" value="Aythu">Aythu</label><br>
<span id="q8"></span><br>
<input type="submit" id="quizSub" class="ui left floated button" value="Submit" onclick="quizCorrection()">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.3/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/c_cpp");
var textarea = $('textarea[name="editor"]');
editor.getSession().on("change", function () {
textarea.val(editor.getSession().getValue());
});
// function getcodeVal(){
// var code = editor.getValue();
// console.log(code);
// }
</script>
<script>$('select.dropdown').dropdown();</script>
</body>
</html>