天天看点

几道 C 语言面试题

几道 c 语言题

1.

int main()

{

 int i, n = 20;

 for (i = 0; i < n; i--)

  printf("*");

 return 0;

}

change/add only one character and print '*' exactly 20 times.

(there are atleast 3 solutions to this problem :-)

2. display below like:

        1

       212

      32123

     4321234

    543212345

3. search for maximum and minimum value, before  save into arrange for any 5 natural number (use multiful for grammer)

ex)

save to any 5 natural number

30 20 75 15 64 <enter>

minimum : 15

maximum : 75

4. use ms-sql of join grammer. show query fot result

table.1

                ac_country

--------------------------------------

country_cd            country_nm

kor                     koera

jpn                     japan

usa                      usa

cha                     china

table.2

                ac_currency1

-------------------------------------------

country_cd     currency_cd     currency_nm

kor              won               w

jpn              yen               y

usa              usd               us

# result

country_nm     currency_cd     currency_nm

korea             won              w

japan             yen              y

usa               usd              us

result query :

5.use ms-sql of join grammer. show query fot result

              account

userid          cost          date

use01          10,000       2007-01-02

use02           5,000       2007-01-03

use05           7,000       2007-01-03

use03           5,000       2007-01-03

use01           5,000       2007-01-04

use04           5,000       2007-01-05

use02          10,000       2007-01-05

use01           1,000       2007-01-05

                 userinfo

-----------------------------------------------

code      userid       money        register

aaa      use01        8,500        2007-01-02

aaa      use02        5,000        2007-01-03

aaa      use03        2,000        2007-01-04

aaa      use04        4,500        2007-01-05

bbb      use05        5,500        2007-01-02

table.3

  stateinfo

-------------------------------------

connect        state        indate

aaa-use01       yes        2007-01-03

aaa-use02        no        2007-01-05

aaa-use03        no        2007-01-04

aaa-use04       yes        2007-01-05

bbb-use05        no        2007-01-04

#result

----------------------------------------------------------

userid    money    account_count   account_total   state

use01     8,500          3            16,000        yes

use02     5,000          2            15,000         no

use03     2,000          1             5,000         no

use04     4,500          1             5,000        yes

6. show 2 query each fot result.a, result.b

table.data_table

-----------------------

       f_date

2007-04-17 11:42:55.200

2007-04-18 01:45:33.403

2007-04-18 01:47:01.500

2007-04-17 11:40:15.000

2007-04-18 11:41:25.700

2007-04-18 11:41:49.420

2007-04-17 11:44:58.000

2007-04-18 11:45:23.340

#result.a

----------

  f_date

2007-04-17

2007-04-18

#result.b

2