U E D R , A S I H C RSS

김신애/for문예제1

~cpp 
#include <iostream.h>
int main()
{
	
	for (int i =1; i < 11 ; i=i++)
	{
		cout<< i << "\t" <<11-i<<endl;
	}
	
	return 0;
}

~cpp 
#include <iostream.h>

int main()				
{
	int b;
	cin >>b;
	for (int a=1;a<10;a=a+1)
	{
		cout << b <<"*"<<a<<"="<<a*b<<endl;
	}
	return 0;
}

~cpp 
#include <iostream.h>

int main()				
{
	for (int b=2;b<10;b=b+1)
	{
		for (int a=1;a<10;a=a+1)
		{
			cout << b <<"*"<<a<<"="<<a*b<<endl;
		}
	}
	return 0;
}
~cpp 
#include <iostream.h>

int main()				
{
	int array[10] = {1,2,3,4,5,6,7,8,9,10};

	for (int i = 0 ; i < 10 ; i++)
		cout << array[i] << endl;

	int array_[10];

	array_[0] = 1;
	array_[1] = 2;
	array_[2] = 3;
	array_[3] = 4;
	array_[4] = 5;
	array_[5] = 6;
	array_[6] = 7;
	array_[7] = 8;
	array_[8] = 9;
	array_[9] = 10;

	for (i = 0 ; i < 10 ; i++)
		cout << array[i] << endl;

	return 0;
}
~cpp 

int 형 배열 10개에 cin으로 입력 받은 값을 저장해서 배열의 합을 출력~!
#include <iostream.h>

int main()				
{
	int array[10] ;

	for (int i = 0; i<10;i++)
	{
		cin>>array[i];
	}

	int c = 0;
	
	for (int b=0;b<10;b=b+1)
	{
		c=c+array[b];
	}

	cout << c << endl;

	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:49
Processing time 0.0203 sec