当前位置: 首页>>代码示例>>C++>>正文


C++ Scanner::nextInt方法代码示例

本文整理汇总了C++中Scanner::nextInt方法的典型用法代码示例。如果您正苦于以下问题:C++ Scanner::nextInt方法的具体用法?C++ Scanner::nextInt怎么用?C++ Scanner::nextInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scanner的用法示例。


在下文中一共展示了Scanner::nextInt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[])
{
#ifndef ONLINE_JUDGE
 
freopen("test.in", "r", stdin);
#endif
 
Scanner sc;
int t = sc.nextInt();int n,i,j;
while(t--)
{
	//scanf("%d",&n);
	n=sc.nextInt();
	int ar[n][n]
	;
	for(i=0;i<n;i++)
	for(j=0;j<=i;j++)
	//scanf("%d",&ar[i][j]);
	ar[i][j]=sc.nextInt();
	
	for(i=n-1;i>0;i--)
	for(j=0;j<i;j++)
	ar[i-1][j]+=ar[i][j]>ar[i][j+1]?ar[i][j]:ar[i][j+1];
	
	printf("%d",ar[0][0]);
	printf("\n");
	}
	return 0;
}
开发者ID:abhiramravi,项目名称:Third-Semester---Programming-Lab,代码行数:29,代码来源:transformexp.cpp

示例2: main

int main( int argc, char* argv[] ) {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif

	Scanner sc;

	//int tc = sc.nextInt();
	int tc=1;
	while(tc--){
		//int m = sc.nextInt();
		//int n = sc.nextInt();
		int n,m;
		scanf("%d%d",&n,&e);
		m=n;
		int s=n+m; //source node
		int t=n+m+1;//sink node
		graphClear(n+m+2);//total nodes are n+m+2
		rep(i,m) {
			int a=sc.nextInt();
			addEdge(s, i, a, 0);//addEdge(source,destination,capacity,cost)
		}
		rep(j,n) {
			int b=sc.nextInt();
			addEdge(m+j, t, b, 0);//addEdge(source,destination,capacity,cost)
		}
开发者ID:sjaljain,项目名称:Programs,代码行数:26,代码来源:FlowApprox.cpp

示例3: main

 public static void main(String args[])
 {
     Scanner in = new Scanner(System.in);
     int t,i,j,k;
     t = in.nextInt();
     for(i=0;i<t;i++)
     {
         int n;
         n = in.nextInt();
         int[] a = new int[5];
         for(j=0;j<n;j++)
         {
             a[j]=in.nextInt();
         }
         for(j=0;j<n;j++)
         {
             for(k=j;k<n;k++)
             {
                 if(a[j]<a[k])
                 {
                     int s=a[j];
                     a[j]=a[k];
                     a[k]=s;
                 }
             }
         }
         for(j=0;j<n;j++)
         System.out.print(a[j] + " ");
         System.outprintln();
     }
 }
开发者ID:mukeshkharita,项目名称:codechef-solutions,代码行数:31,代码来源:sorting.c

示例4: main

int main()
{
	scanf("%d %d",&V,&E);

	ne = 0;
	memset(last, -1, sizeof last);
	memset(next, -1, sizeof next);
	memset(parent, -1, sizeof parent);
	memset(rank, 0, sizeof rank);

	Scanner inp;

	for(int i=0 ; i<E ; i++)
	{
		//scanf("%d %d %d", &e[i].s, &e[i].t, &e[i].w);
		e[i].s = inp.nextInt();
		e[i].t = inp.nextInt();
		e[i].w = inp.nextInt();
		e[i].w = - e[i].w;
	}

	//for(int i=0 ; i<V ; i++) parent[i] = i, rank[i] = 0;

	qsort(&e, E, sizeof(edges), cmp);

	int k=0;	
	for(int i=0 ; i<E && k<V-1; i++)
	{
		int u = find(e[i].s);
		int v = find(e[i].t);
		if(u != v)
		{
			addedge(e[i].s, e[i].t, -e[i].w);
			addedge(e[i].t, e[i].s, -e[i].w);
			k++;
			_union(u,v);
		}
	}
	
	for(int i=0 ; i<V ; i++)
	{
		getScore(i);
		for(int j=0 ; j<V ; j++)
			printf("%d ", dist[j]);
		printf("\n");
	}
}
开发者ID:Rahul2025,项目名称:Thesis,代码行数:47,代码来源:q105_mem.cpp

示例5: main

	public static void main(String... args)
	{
		int N,T;
      Scanner s = new Scanner(System.in);
      T = s.nextInt();
      N = s.nextInt();
      if((1<=N  && N>=1000000) && (1<=T && T<=10))
              System.exit(0);
      
      int a[][] = new int[N][3];
      for(int i = 0 ;i<N;i++)
      {
       	for(int j = 0;j<3;j++)
        {
          a[i][j]=s.nextInt();  
      	  
//          if(a[i][j] >=100000)
  //            System.exit(0);
        }
     }     
 for(int i = 0 ;i<N;i++)
      {
        for(int j = 0;j<3;j++)
        {
		System.out.println("\t"+a[i][j]);
        }
     }

      int f=0,sum=0;
	  for(int i = 0 ;i<N;i++)
      {
        int min=a[i][0];
        for(int j = 0;j<3;j++)
        {
      		if(min>a[i][j] && f!=j)
            {
              min = a[i][j];
              f=j;
            }
        }
        sum+=min;
      }
      System.out.println(sum+"");
	}	
开发者ID:GowthamShanmugam,项目名称:ProGeeks_IDE,代码行数:44,代码来源:shopping.cpp

示例6: main

int main( int argc, char* argv[] ) {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	
	#endif

	/*
	freopen("input-nn.txt","w",stdout);
	cout<<1<<endl;
	int n=100000;
	cout<<n<<endl;
	set<pii> s;
	rep(i,n){
	int x=rand();
	int y=rand();
	pii p=mp(x,y);
	if(s.count(p)){i--; continue;}
	s.insert(p);			
	cout<<x<<" "<<y<<endl;
	}
	exit(0);
	*/

	Scanner sc;
	int testCases = sc.nextInt();
	for(int testCase=1;testCase<=testCases;testCase++){
		int n = sc.nextInt();
		vpii p(n);
		rep(i,n){
			p[i].first = sc.nextInt();
			p[i].second= sc.nextInt();
		}

		buildTree(0, n, &(vpii(p)[0]));

		//fprintf(stderr,"time=%.3lfsec\n",0.001*(clock()-start));

		rep(i,n){
			findNearestNeighbour(n, p[i].first, p[i].second);
			printf("%lld\n", closestDist);			
		}
开发者ID:Aakash1996,项目名称:spoj-1,代码行数:41,代码来源:MLE.cpp

示例7: main

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif

	Scanner sc;

	int V1 = sc.nextInt();
	int V2 = sc.nextInt();
	init(V1, V2);
	int e = sc.nextInt();

	while(e--){
		int u = sc.nextInt() - 1;
		int v = sc.nextInt() - 1;
		addEdge(u, v);
	}

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

	return 0;
}
开发者ID:sjaljain,项目名称:Programs,代码行数:22,代码来源:MATCHING-SPOJ-HOPCRAFT.cpp

示例8: main

int main( int argc, char* argv[] ) {
	#ifndef ONLINE_JUDGE
	freopen("input-nn.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif	

	Scanner sc;
	int testCases = sc.nextInt();
	for(int testCase=1;testCase<=testCases;testCase++){
		int n = sc.nextInt();
		vpii p(n);
		rep(i,n){
			p[i].first = sc.nextInt();
			p[i].second= sc.nextInt();
		}

		root = buildTree(0, n, &(vpii(p)[0]));

		//fprintf(stderr,"time=%.3lfsec\n",0.001*(clock()-start));

		rep(i,n){
			findNearestNeighbour(p[i].first, p[i].second);
			printf("%lld\n", closestDist);			
		}
开发者ID:Aakash1996,项目名称:spoj-1,代码行数:24,代码来源:MLE-nodes.cpp

示例9: readElement

/*****************************************************************************
 * Function 'readElement'
 * This function takes in a scanner and reads the next integer value, storing
 * it as the element
 *
 * Parameters
 *    inFile: the scanner to be read from
**/
void OneRecord::readElement(Scanner& inFile)
{
  long long inValue = 0;
  inValue = inFile.nextInt();
  this->setElement(inValue);
}
开发者ID:ev0xfrost,项目名称:CSCE240-finalproject,代码行数:14,代码来源:OneRecord.cpp


注:本文中的Scanner::nextInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。