C++ vs C Los códigos de C++ están copiados de la documentación de PRO1.

Slides:



Advertisements
Presentaciones similares
Practica
Advertisements

Los Números y El Tiempo. Los Números Más de = once 12 = doce 13 = trece 14 = catorce 15 = quince 16 = dieciseis 17 = diecisiete 18 = dieciocho 19.
Introducción a C++ Sistemas Operativos
You need to improve the way you write and think in Spanish - Time This is an interactive presentation. You need your work sheet, your pencil, and your.
La hora. ¿Qué hora es? Son las ocho= Its 8 oclock Son las ocho= Its 8 oclock Son las cinco= It's 5 oclock Son las cinco= It's 5 oclock Son las seis=Its.
Goal: Factor trinomials of the form ax2 + bx + c
Telling Time Grammar Essential #8.
Para Empezar Hoy en lunes el veintinueve de octubre Write the times below in Spanish. 2:59- 9:31- 10:04- 5:17- Answer the question below (look at the clock.
Para Empezar Hoy en martes el treinta de octubre Quiz Review Write the times below in Spanish. 5:31- 12:59- 8:15- 2:22-
ALC 53 lunes el 14 de diciembre Use your own paper for this weeks ALC. You will turn them in on Friday.
Beginning Low ESL Teacher
¿Qué hora es?. Es la una. Son las tres. Son las once.
The Plurals of Adjectives
¿Qué hora es? What time is it? (What hour is it?).
¿Qué hora es? Capítulo – Para Empezar. ¿Qué hora es? To state the time in Spanish, one must use the phrase Es la… or Son las… To state the time in Spanish,
Ordenamiento de Arreglos
Searching data in Arrays COMP 242. Linear Search Algoritmo: Comenzando con el primer elemento, se compara cada uno con el valor a buscar y se detiene.
Arithmetic Operators & Operators Precedence
Ejemplo de un programa en C++ donde se manipulan archivos de datos
Superlatives Page 280 Realidades 1.
Telling Time. ¿Qué hora es? What time is it? Es la una. It is one oclock. Son las dos (tres, cuatro…) It is two oclock. Son las dos y cuarto. It is 2:15.
The Uses of Por and Para ¡En Español! Unidad 1 Etapa 2.
Entrada: Los verbos en la historia (Entrance: Verbs in the story) Copy the date and title, and log the entry in your table of contents. Take a Realidades.
Programando con Hilos POSIX* Intel Software College.
generic constraint development environment
Ejemplo de Programa C++
Entrada y salida Fundamentos de programación/Programación I
Lunes, el 9 de septiembre Actividades en clase. Timed Writing Use your Spanish vocabulary (open-notes) to write a 50 word story in Spanish. Use your imagination,
LOGROS DEL PERÍODO Utiliza de forma correcta las funciones para entrada y salida de datos en c++. Utiliza los elementos básicos de un programa en c++.
When we ask what time it is in Spanish, we say “¿Qué hora es?”
A partir del lenguaje C Entorno de programación Visual C++
(por favor) By emory gibson Para describir how long ago en español, presta attencion.
TOPIC: ¿Qué hora es?. Es la…. Son las … mediodía medianoche de la mañana de la tarde de la noche media cuarto en punto It is… noon midnight in the morning.
Telling Time (Cómo decir la hora). When we ask what time it is in Spanish, we say “¿Qué hora es?” Some people also say “¿Qué horas son?”
Cap. 11 Sec. 33  Hace tres años que vivo en Gainesville.  Miguel y Ana juegan tenis hace veinte minutos.  Hace cuatro días que llueve.  Nosotros estamos.
Telling time in Spanish: Explanation Practice exercise index McCarron.
SOBRECARGA DE FUNCIONES
Martes el 9 de noviembre Bienvenida You need an orange book.
Me llamo ________ Clase 10 NM La fecha es el 2 de febrero del 2012 Propósito # 28: ¿Cómo repasamos para el examen de la Unidad 7? Actividad Inicial: Escribe.
Me llamo ________ Clase 10 NM La fecha es el Primero de febrero del 2012 Propósito # 27: ¿Cómo vives? Actividad Inicial: Copia y responde en oraciones.
Pg. 28.  To answer this question in Spanish you say: ◦ Es la una. 1:00 ◦ Son las (+ número)  i.e. Son las dos. 2:00.
Repaso (parte 2) Español 2. Como escribir una pregunta…  Adónde (to where)  Cómo (how)  Cuál/Cuáles (which ones)  Cuándo (when)  Cuánto (how much)
1 Chapter 8 Scope Dale/Weems/Headington. 2 Tópicos del Capítulo 8 l Local Scope vs. Global Scope of an Identifier l Detailed Scope Rules to Determine.
4A4A4A4A Grado en Ingeniería Informática Grado en Ingeniería del Software Grado en Ingeniería de Computadores Luis Hernández Yáñez Facultad de Informática.
LIA. SUEI CHONG SOL, MCE.. #include void main() { float N1,N2,N3,SUMA; cout>N2;
Introducción a la Computación
Sección 5-2 Estructuras de Control de Decisión Expresiones Lógicas.
Preparado por: Nelliud D. Torres Enero/2003 Versión 1.0
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 2- 1.
Arreglos Ejemplo paso a paso. Planteamiento Como estudiante de ingeniería, quieres usar tus habilidades de programador para llevar un registro de tus.
ARREGLOS O ARRAYS.
¿A qué hora? At what time?  Las dos… ¿A qué hora?  La una.
IntroducciÓn a los Arreglos (“arrays”) en C++
Lenguaje C++ Problemas.
#5- Los Artículos Definidos y Indefinidos (Definite and Indefinite
Searching data in Arrays
Please write the following vocabulary words into your notebooks
Arreglos en C++ (una y dos dimensiones)
Telling Time: ¿Qué hora es?
Telling time to the minute, using “y” and “menos”.
¿Qué hora es?.
Avancemos 1 – Unidad 2 Lección 1
Son las dos It is 2 A las 2 – at 2 Son las – it is 2
Capítulo 1 Lección B Vocabulario II
¿Qué hora es?.
Telling Time ¿Cómo se dice en Español “Time”? el tiempo
Registros tipo struct PROGRAMACIÓN MODULAR.
Arrays Programming COMP102 Prog. Fundamentals I: Arrays / Slide 2 Arrays l An array is a collection of data elements that are of the same type (e.g.,
¿Qué hora es?.
Que hora es? What time is it?.
Transcripción de la presentación:

C++ vs C Los códigos de C++ están copiados de la documentación de PRO1

Primer programa: suma #include using namespace std; // This program reads two numbers and // writes their sum int main() { int x, y; cin >> x >> y; int s = x + y; cout << s << endl; } #include #define STDOUT 1 //This program receives two numbers //and writes their sum int main(int argc,char *argv[]) { int x,y; char buff[128]; x=atoi(argv[1]); y=atoi(argv[2]); int s=x+y; sprintf(buff,"%d\n",s); write(STDOUT,buff,strlen(buff)); }

Como se utilitza > suma > suma > suma > suma

Comparativa O Los includes llevan.h (hay que mirar cuales hacen falta para cada función) O man strlen, man sprintf, etc O En C++ se leen los datos de la entrada std (lo haremos al final del curso) O En C para entrada de datos sencillos (argumentos del programa sencillos) se reciben como parámetros del main O La entrada/salida de datos hay que procesarla en C explícitamemte O Los parámetros siempre son strings  pasarlo a int O La salida, si es la consola, hay que pasarla a string

Decompose_time #include using namespace std; // This program reads a natural number that represents an amount // of time in seconds and writes the decomposition in hours, // minutes and seconds int main() { int N; cin >> N; int h = N / 3600; int m = (N % 3600) / 60; int s = N % 60; cout << h << " hours, " << m << " minutes and " << s << " seconds" << endl; } #include #define STDOUT 1 // This program receives a natural number that represents an amount // of time in seconds and writes the decomposition in hours, // minutes and seconds int main(int argc, char *argv[]) { int N; N=atoi(argv[1]); int h = N / 3600; int m = (N % 3600) / 60; int s = N % 60; char buff[128]; sprintf(buff,"%d hours, %d minutes and %d seconds\n",h,m,s); write(STDOUT,buff,strlen(buff)); }

Tipos datos O int x,i,j; O Arithmetic operators: +, ‐, *,/, % O char a,b,c; O bool A; O string O int x,i,j; O Arithmetic operators: +, ‐, *,/, % O char a,b,c; O bool A; // no existe O String // No existe No se pueden aplicar operadores básicos de string en C, hay que usar: - strlen :para calcular la longitud “usada” de un string, (es diferente del tamaño) - strcmp: para comparar dos strings

Tipos datos O Conversión explícita tipos O char(i), int(‘a’)ç O Visibilidad O Vectores O vector name(n); O vector S(n); O int x=S[0]; O Conversión explícita tipos O (char) i, (int)’a’ O Visibilidad (igual) O Vectores O tipo name[n]; O int S[n]; O int x=S[0]; No existe vector.h en C, sólo hay operaciones básicas. Para conocer el tamaño en BYTES de cualquier variable tenemos la función sizeof

Ejemplo: Min value of a vector // Pre: A is a non ‐ empty vector // Post: returns the min value of the vector int minimum(const vector & A) { int n = A.size(); int m = A[0]; // visits A[0] // loop to visit A[1..n ‐ 1] for (int i = 1; i < n; ++i) { if (A[i] < m) m = A[i]; } return m; } // Pre: A is a non ‐ empty vector // Post: returns the min value of the vector int minimum(int *A, int size_A) { int n = size_A int m = A[0]; // visits A[0] // loop to visit A[1..n ‐ 1] for (int i = 1; i < n; ++i) { if (A[i] < m) m = A[i]; } return m; }

Constantes O const tipo_dato nombre_variable=valor; O #define nombre_variable valor

Operadores O Asignación = O Comparación >, =,<=, == O Logicas: && (AND), || (OR) O AND y OR no existen en C !! O Para utilizar “booleanos” en C se usan normalmente enteros

Estructuras condicionales if (condicion) statements else if (condicion) statements else statements Si hay más de un statement, se pone entre llaves {}

Estructuras iterativas O While  igual O While (condition) statements O For  igual O for(S_init;condition;S_iter) S_body;