yb-oi培训记要

7.22 3hours

play movie: Obama programing for an hour a day, no teaching in school,Zuckerberg

noip's introduction

maze blockly, no try

dev c++, 5.11

first program: cout<<"hello world ";

IPO:

declare var: type name1,name2; //int double char bool string

input: 

cin>>var_name1>>var_name2; //cin>>a>>b;

scanf("%d",&a); 

process:

var_name=expression; //a=5; y=x*x+2*x+1;

output:

cout<

printf("%.2lf",sum);

three basic structers of Programs

Sequence Structure:

cin>>a>>b;

t=a; a=b; b=t;

math expression:

% 7%3=1

/  7/3=2

((x-y)*x+5*x)*y+y*y

a=n%10;

b=n/10%10;

c=n/100;

 

branch structure:

make computer smart

relational expression: > < >= <= == !=

logical expression: && || !

if( condition expression){ statement;}

else { statement;}

if( a%2==0) cout<<"even";

else cout<<"odd";

if(year%4==0&&year%100!=0||year%400==)cout<<"leap year";

if(a

if(a

if(a

if(a

if(b

if(score>=75&&score<90) cout<<"better";

 

0723

nesting

if(month==4||month==6||moth==9||moth==11)

  d=30;

else if(month==2){

          if(year==leap_year) d=29;

         else d=28;

     }

    else d=31;

switch(expression){

  case value1: statement;break;

  case value2:statement;break;

  default:statement;

}

 

loop structure:

computer's fast speed

while(condition expression){

  statement

}

counter:

char c;

cin>>c;

while(c!='#'){

  if(c=='a'||c=='A') count++;

  cin>>c;

}

cout<

 

cin>>n;

i=count=0;

while(i

  cin>>a;

  if(a%2==0) count++;

  i++;

}

cout<

 

accumulator:

cin>>n;

sum=0;

for(i=0;i

  cin>>ai>>bi;

  if(bi=='Y') sum+=ai;

}

cout<

 

table:

do{

  cin>>c;

  if(c=='W')w++;

  if(c=='L')l++;

  if(w>10&&w-l>1||l>10&&l-w>1){

  cout<

  w=l=0;

}

}while(c!='E')

 

0724

Small Algorithms and Skills

Maximum

Minimum

prime number(marking)

Exhaustion

Fibonacci

gcd

lcm

Recurrence(iteration)

 

write the results of programs

 

multiple loops

write the stars

a row

a row×column

Hundreds of dollars and hundreds of chickens

Optimization of algorithm

 

0725

sum, Simulation

count: exhaustive, divide number, counter

 

exercise:

golden coin

open the door

interesting prime

 

one dimensional array

type name[const expression];

int a[50];

a[0],a[1]...a[49]

 

IPO

cin>>n;

for(i=0;i>a[i];

memset(a,0,sizeof(a));

int a[50]={0,1}

for(i=n-1;i>=0;i--)cout<

 

enter the  scores of n students , print out the number and score of student whose  score is lower than average

output the numbers of the same number: counter

Taotao pick appples: counter

calculate the money of books: use array as constant

age and ills: use array as counters

bucket sort: use array as counters and sort

 

fibonacci

see the results the program

#include

int main(){

   int i,j,h,m,n,k;

   int b[11];

   scanf("%d",&n);

   for(i=1;i<=10;i++){

       m=n;

       j=11;

       while(m>0){

           j--;

           b[j]=m%10;

           m/=10;

       }

       for(h=j;h<=10;h++)

           n+=b[h];

   }

   printf("%d\n",n);

   return 0;

}

input:1234

output:

 

 

 

save plan:

 

stairs

Palindrome number

Binary Conversion

sort

 

Two-dimensional array

int student[50][7];

Saddle number

 

function

type name(parameters){

  return ?;

}

name(parameters);

Parametric function

void

return value

 

recursive

Reverse order

Factorial

 

0726

High Precision Computation

bubble sort

insert sort

Bucket sort

quick sort

merge sort

 

0727

search

eight queens

simple dynamic plan

 

0728

test

freopen

create input file

lemon

 

 

 

 

你可能感兴趣的:(OI)