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<<a<<"+"<<b<<'='<<sum;

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<b)a=b;

if(a<c)a=c;

if(a<b){t=a;a=b;b=t;}

if(a<c){t=a;a=c;c=t;}

if(b<c){t=b;b=c;c=t;}

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<<count;

 

cin>>n;

i=count=0;

while(i<n){

  cin>>a;

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

  i++;

}

cout<<count;

 

accumulator:

cin>>n;

sum=0;

for(i=0;i<n;i++){

  cin>>ai>>bi;

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

}

cout<<sum;

 

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<<endl;

  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<n;i++)cin>>a[i];

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

int a[50]={0,1}

for(i=n-1;i>=0;i--)cout<<a[i]<<' ';

 

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 <stdio.h>

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

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值