Results 1 to 5 of 5
Thread: C
Hybrid View
-
22nd April 2009 01:36 #1
C
, ... , .

, . , . , "printf (p);" , .Code:#include <iostream.h> #include <string.h> #include <stdio.h> int main () { char str[10], *p; printf ("Enter string: "); gets (str); p=str; while (*p && *p!=' ') p++; printf (p); system ("pause"); return 0; }
:
while(*p) { printf (*p); p++;} . , , printf (p) p. ?
-
22nd April 2009 01:54 #2
- printf. , printf("%s", p);. ( ) - printf("%c", *p);.
, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
22nd April 2009 07:37 #3
printf(p) , p, , printf. , (%), . ... ,
putchar(*p). p ( , , ), printf("%x", p).
Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others
-
22nd April 2009 09:24 #4
-
3rd May 2009 22:25 #5
,
:
unsigned a[5][5]. void fillMatrix (a[][5], unsigned n), a[][] :
, . ., , 1-4, 5-7, 8-9, 10, (a[0][0] a[n][n] ). , , a[4][5] ( a[5][5]) 11, - 11-14, 15-17, 18-19, - 20. :
0 20 19 17 14
1 0 18 16 13
2 5 0 15 12
3 6 8 0 11
4 7 9 10 0
, .
Code:#include <iostream.h> #include <iomanip.h> using namespace std; void fillMatrix(unsigned a[][5], unsigned n); unsigned int a[5][5], i, j, step = 0; const int n = 5; int main (void) { fillMatrix (a, n); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) cout<<setw(5)<<a[i][j]; cout<<endl; } system ("pause"); return 0; } void fillMatrix(unsigned a[][5], unsigned n) { for(i=0; i<n ; i++) for(j=0; j<n; j++) a[i][j]=0; for (j=0; j<n-1; j++) for (i=1; i<n; i++) { step++; a[i][j] = step; } step = 21; for (j=1; j<n; j++) for (i=0 ; i<j ; i++) { step--; a[i][j] = step; } }Last edited by 0wn3r; 4th May 2009 at 00:04.




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in