Online Judge System Tom Chao Zhou CSC2100B Data Structures Tutorial 2.

Slides:



Advertisements
Similar presentations
C Characters & Strings Character Review Character Handling Library Initialization String Conversion Functions String Handling Library Standard Input/Output.
Advertisements

Contest format 5 hours, around 8-12 problems One computer running (likely)Linux, plus printer 3 people on one machine No cell phones, calculators, USB.
CS1010 Programming Methodology
Zhang Hongyi CSCI2100B Data Structures Tutorial 2
CSC Programming for Science Lecture 5: Actual Programming.
Dale Roberts Basic I/O – scanf() CSCI 230 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Department of.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
C programming an Introduction. Types There are only a few basic data types in C. char a character int an integer, in the range -32,767 to 32,767 long.
1 CSE1301 Computer Programming: Lecture 9 Input/Output.
1 Agenda Variables (Review) Example Input / Output Arithmetic Operations Casting Char as a Number (if time allow)
Basic Input/Output and Variables Ethan Cerami New York
C Formatted Input/Output /* Using Integer Conversion Specifiers */ #include int main ( ) { printf( "%d\n", 455 ); printf( "%i\n", 455 ); printf( "%d\n",
C Programming Day 2 based upon Practical C Programming by Steve Oualline CS550 Operating Systems.
CSE 332: C++ program structure and development environment C++ Program Structure (and tools) Today we’ll talk generally about C++ development (plus a few.
C Programming. Chapter – 1 Introduction Study Book for one month – 25% Learning rate Use Compiler for one month – 60%
CS 161 Introduction to Programming and Problem Solving Chapter 13 Console IO Herbert G. Mayer, PSU Status 9/8/2014 Initial content copied verbatim from.
C PROGRAMMING LECTURE 17 th August IIT Kanpur C Course, Programming club, Fall by Deepak Majeti M-Tech CSE
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
C programming for Engineers Lcc compiler – a free C compiler available on the web. Some instructions.
Lecturer: Omid Jafarinezhad Sharif University of Technology Department of Computer Engineering 1 Fundamental of Programming (C) Lecture 4 Input and Output.
Sales person receive RM200/week plus 9% of their gross sales for that week. Write an algorithms to calculate the sales person’s earning from the input.
Chapter 3 Processing and Interactive Input. 2 Assignment  The general syntax for an assignment statement is variable = operand; The operand to the right.
1 計算機程式設計 Introduction to Computer Programming Lecture01: Introduction and Hello World 9/10/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction.
CHAPTER 2 PART #3 INPUT - OUTPUT 1 st semester King Saud University College of Applied studies and Community Service Csc
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Numeric types of C Integers – Signed and unsigned – In a few different sizes – 209 Floating point – In different sizes –
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Chapter 2 Simple Data Types By C. Shing ITEC Dept Radford University.
1.Identifiers 2.Variables 3.Keywords 4.Statements 5.Comments 6.Whitespaces 7.Syntax 8.Semantic © In this session we will.
Introduction to Programming
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
3. FORMATTED INPUT/OUTPUT. The printf Function The first argument in a call of printf is a string, which may contain both ordinary characters and conversion.
CSC141- Introduction to Computer programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 21 Thanks for Lecture Slides:
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
1 CSC2100B Data Structure Tutorial 1 Online Judge and C.
CSE1301 Computer Programming: Lecture 6 Input/Output.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Input and Output.
Variables Symbol representing a place to store information
Basic Types CGS 3460, Lecture 19 Feb 22, 2006 Hen-I Yang.
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
Operating System Discussion Section. The Basics of C Reference: Lecture note 2 and 3 notes.html.
Computer Programming for Engineers
Department of Electronic & Electrical Engineering IO reading and writing variables scanf printf format strings "%d %c %f"
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Principles of Programming - NI Chapter 10: Character & String : In this chapter, you’ll learn about; Fundamentals of Strings and Characters The difference.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 2.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
Formatted Input and Output
A bit of C programming Lecture 3 Uli Raich.
ECE Application Programming
ECE Application Programming
Input/output.
Administrative things
Input and Output Lecture 4.
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Chapter 08- printf and scanf
CSI 121 Structured Programming Language Lecture 7: Input/Output
Chapter 4 Managing Input and Output Operations
More Loops Topics Relational Operators Logical Operators for Loops.
Administrative things
Presentation transcript:

Online Judge System Tom Chao Zhou CSC2100B Data Structures Tutorial 2

Online Judge Writing Your Assignment Program.  Write your program using your favorite editor, e.g. vi, vim, pico, emacs, Visual Studio 2008, etc. Add a header at the first line of your program.

Online Judge /* a assg0_question0 */ #include int main(int argc, char **argv) { int a, b; printf("Please enter two numbers: \n"); scanf("%d %d", &a, &b); printf("The numbers you entered are %d and %d \n", a, b); printf("And their sum is %d \n", a + b); return 0; }

Online Judge /* a assg0_question0 */ Course Code: Student ID: Login ID: a Problem ID: assg0_question0

Online Judge Submitting Your Program  Compile and test your program in Unix (Linux, Sparc) To Compile in Unix:  gcc –o myprogram myprogram.c To Run: ./myprogram  Submit to Online Judge when ready Login to a sparc(or linux) machine mail <  Wait for reply in your CSE mailbox  For those who are not CSE students, send your student id and name to TA before this Friday(29, Jan) to get an account.

Online Judge Online Judge Reply Messages Accepted  Congratulation Submission Error  Check your header line Compile Error

Online Judge Runtime Error  Time Limit Exceeded Check your algorithm. Infinite loops?  Output Limited Exceeded Check your algorithm. Infinite loops?  Float Point Exceptions Division by 0  Segmentation Fault,... Check your code, e.g. errors in pointers. Wrong Answer. Presentation Error.

Online Judge A word about ”Presentation Error” Make sure your output is EXACTLY the same as the specification, (or sample program, if provided).  Check for upper case / lower case letters.  Check for extra spaces / extra blank lines. There should be no extra spaces at the end of a line, and no extra blank lines at the end of the outputs.

Online Judge Demostration Question Id: 2010A0Q0 Write a program to calculate the products of two integers.  Input the number of products to be computed.  While the number of products is not exceeded, do: Input two integers. Display their product.  You can assume the inputs are within the range 0 < x < Sample inputExpected output 3P: 2 1 2P: P:

Scanf Printf type Input dType signed int represented in base 10. Digits 0 through 9 and the sign (+ or -). iType signed int. The base (radix) is dependent on the first two characters. If the first character is a digit from 1 to 9, then it is base 10. If the first digit is a zero and the second digit is a digit from 1 to 7, then it is base 8 (octal). If the first digit is a zero and the second character is an x or X, then it is base 16 (hexadecimal). oType unsigned int. The input must be in base 8 (octal). Digits 0 through 7 only. uType unsigned int. The input must be in base 10 (decimal). Digits 0 through 9 only. x, XType unsigned int. The input must be in base 16 (hexadecimal). Digits 0 through 9 or A through Z or a through z. The characters 0x or 0X may be optionally prefixed to the value. e, E, f, g, G Type float. Begins with an optional sign. Then one or more digits, followed by an optional decimal-point and decimal value. Finally ended with an optional signed exponent value designated with an e or E. sType character array. Inputs a sequence of non-whitespace characters (space, tab, carriage return, new line, vertical tab, or formfeed). The array must be large enough to hold the sequence plus a null character appended to the end. scanf(“%d”,&x) printf(“%d”,x)

scanf printf modifier scanf type Effect hd, i, o, u, x The argument is a short int or unsigned short int. ld, i, o, u, x The argument is a long int or unsigned long int. le, f, gThe argument is a double. Le, f, gThe argument is a long double.

/* xx loginid WRONG-QID */ #include int main(int argc, char **argv) { short a = 0; short b = 0; short p; int i=0; int count; scanf("%d", &count); while (i < count) { scanf("%hd %hd", &a, &b); p=a*b; printf("P: %hd \n", p); } return 0; } //Submission Error: Please check the header format of your program. //Attemp 1

/* xx loginid 2010A0Q0 */ #include int main(int argc, char **argv){ short a = 0; short b = 0; short p; int i=0; int count; scanf("%d", &count); while (i < count) { scanf("%hd %hd", &a, &b); p=a*b; printf("P: %hd \n", p); } return 0; } //Runtime Error: Output Limit Exceeded. //Attemp #2

/* xx loginid 2010A0Q0 */ #include int main(int argc, char **argv){ short a = 0; short b = 0; short p; int i=0; int count; scanf("%d", &count); while (i < count) { scanf("%hd %hd", &a, &b); p=a*b; printf("P: %hd \n", p); i++; } return 0; } //Wrong Answer: Please check your program. //Attemp #3 //short 16bits – //int 32 bits – 4*10^9 //long long 64 bits – 1*10^19

/* xx loginid 2010A0Q0 */ #include int main(int argc, char **argv){ short a = 0; short b = 0; int p; int i=0; int count; scanf("%d", &count); while (i < count) { scanf("%hd %hd", &a, &b); p=a*b; printf("P: %d \n", p); i++; } return 0; } //Presentation Error //Attemp #4

/* xx loginid 2010A0Q0 */ #include int main(int argc, char **argv){ short a = 0; short b = 0; int p; int i=0; int count; scanf("%d", &count); while (i < count) { scanf("%hd %hd", &a, &b); p=a*b; printf("P: %d\n", p); i++; } return 0; } //Accepted: Congratulations! //Attemp #5

Check your score:  Method to calculate your score:  /* To be reconfirmed */  /* Will be adjusted for each assignment */  /* Note: The score is for reference only, */  /* and does not reflect your final grade */  = (0, 4, 3, 2, 1, 0, 0, 0, 0, 0);  the 0th entry is no use, the 1st entry is the number of award times in the 1st day.  pen = # of submissions -1-award[x]; //x is the day when you successfully finish the program  if (pen<0){  pen = 0;  }  mark = 30 + (70-$pen*5);

Check the question id on the course page. Programming Asgn1:  116  118

Q & A